Part Number Hot Search : 
PDI1394L 2040C MC1455P1 2SD15 ISL8009 A221MHA0 AI3D9 ML12038
Product Description
Full Text Search
 

To Download PIC12F683 Datasheet File

  If you can't view the Datasheet, Please click here to try to view without PDF Reader .  
 
 


  Datasheet File OCR Text:
  ? 2003 microchip technology inc. advance information ds41211a PIC12F683 data sheet 8-pin flash-based 8-bit cmos microcontrollers with nanowatt technology
ds41211a-page ii advance information ? 2003 microchip technology inc. information contained in this publication regarding device applications and the like is intended through suggestion only and may be superseded by updates. it is your responsibility to ensure that your application m eets with your specifications. no representation or warranty is given and no liability is assumed by microchip technol ogy incorporated with respect to the accuracy or use of such information, or infringement of patents or other intellectual property rights arising from such use or otherwise. use of mi crochip?s products as critical components in life support syst ems is not authorized except with express written approval by microchip. no licenses are conveyed, implicitly or ot herwise, under any intellectual property rights. trademarks the microchip name and logo, the microchip logo, accuron, dspic, k ee l oq , mplab, pic, picmicro, picstart, pro mate and powersmart are registered trademarks of microchip technology incorporated in the u.s.a. and other countries. amplab, filterlab, micro id , mxdev, mxlab, picmaster, seeval and the embedded control solutions company are registered trademarks of micr ochip technology incorporated in the u.s.a. application maestro, dspicdem, dspicdem.net, ecan, economonitor, fansense, flexrom, fuzzylab, in-circuit serial programming, icsp, icepic, microport, migratable memory, mpasm, mplib, mplink, mpsim, pickit, picdem, picdem.net, powercal, powerinfo, powermate, powertool, rflab, rfpic, select mode, smartsensor, smartshunt, smar ttel and total endurance are trademarks of microchip technology incorporated in the u.s.a. and other countries. serialized quick turn programming (sqtp) is a service mark of microchip technology incorporated in the u.s.a. all other trademarks mentioned he rein are property of their respective companies. ? 2003, microchip technology incorporated, printed in the u.s.a., all rights reserved. printed on recycled paper. note the following details of the code protection feature on microchip devices:  microchip products meet the specification cont ained in their particular microchip data sheet.  microchip believes that its family of products is one of the mo st secure families of its kind on the market today, when used i n the intended manner and under normal conditions.  there are dishonest and possibly illegal methods used to breach the code protection feature. all of these methods, to our knowledge, require using the microchip produc ts in a manner outside the operating specif ications contained in microchip's data sheets. most likely, the person doing so is engaged in theft of intellectual property.  microchip is willing to work with the customer who is concerned about the integrity of their code.  neither microchip nor any other semicondu ctor manufacturer can guarantee the security of their code. code protection does not mean that we are guaranteeing the product as ?unbreakable.? code protection is constantly evolving. we at microchip are comm itted to continuously improving t he code protection features of our products. attempts to break microchip?s c ode protection feature may be a violation of the digital millennium copyright act. if such acts allow unauthorized access to your software or other copyrighted work, you may have a right to sue for relief under that act. microchip received qs-9000 quality system certification for its worldwide headquarters, design and wafer fabrication facilities in chandler and tempe, arizona in july 1999 and mountain view, california in march 2002. the company?s quality system processes and procedures are qs-9000 compliant for its picmicro ? 8-bit mcus, k ee l oq ? code hopping devices, serial eeproms, microperipherals, non-volatile memory and analog products. in addition, microchip?s quality system for the design and manufacture of development systems is iso 9001 certified.
2003 microchip technology inc. advance information ds41211a-page 1 PIC12F683 high performance risc cpu  only 35 instructions to learn - all single-cycle instructions except branches  operating speed: - dc - 20 mhz oscillator/clock input - dc - 200 ns instruction cycle  interrupt capability  8-level deep hardware stack  direct, indirect and relative addressing modes special microcontroller features  precision internal oscillator - factory calibrated to 1% - software selectable frequency range of 8 mhz to 31 khz - two-speed start-up mode - crystal fail detect for critical applications - clock mode switching during operation for power savings  power-saving sleep mode  wide operating voltage range. (2.0v-5.5v)  industrial and extended temperature range  power-on reset (por)  power-up timer (pwrt) and oscillator start-up timer (ost)  brown-out detect (bod) with software control option  enhanced low current wa tchdog tim er (wd t) with on-chip oscillator (software selectable nominal 268 seconds with full prescaler) with software enable  multiplexed master clear with pull-up/input pin  programmable code protection  high endurance flash/eeprom cell - 100,000 write flash endurance - 1,000,000 write eeprom endurance - flash/data eeprom retention: > 40 years low power features  standby current: - 1 na @ 2.0v, typical  operating current: -8.5 , .0, 100 1 , .0, 1 .0, ( ) ( ) 10 0 1 1 1 1 , , , , 1 , 1. , 00 10 , 0 ( ) 10 () 1 () () () 1 0 1 1 1 , .. . , ,0. .. .
PIC12F683 ds41211a-page 2 advance information ? 2003 microchip technology inc. pin diagram 8-pin pdip, soic, dfn-s v dd gp5/t1cki/osc1/clkin gp4/an3/t1g /osc2/clkout gp3/mclr /v pp v ss gp0/an0/cin+/icspdat gp1/an1/cin-/v ref /icspclk gp2/an2/t0cki/int/cout/ccp1 PIC12F683 1 2 3 4 8 7 6 5
? 2003 microchip technology inc. advance information ds41211a-page 3 PIC12F683 table of contents 1.0 device overview ............................................................................................................. ............................................................. 5 2.0 memory organization ......................................................................................................... .......................................................... 7 3.0 oscillator configurations ..................................... .............................................................. ......................................................... 19 4.0 gpio ports .................................................................................................................. ............................................................... 33 5.0 timer0 module ............................................................................................................... ............................................................ 41 6.0 timer1 module with gate control............................................................................................. .................................................. 43 7.0 timer2 module ............................................................................................................... ............................................................ 47 8.0 capture/compare/pwm (ccp) module ............................................................................................ ......................................... 49 9.0 comparator module........................................................................................................... ......................................................... 55 10.0 analog-to-digital converter (a/d) module................................................................................... ............................................... 63 11.0 data eeprom memory ......................................................................................................... .................................................... 73 12.0 special features of the cpu................................................................................................ ...................................................... 77 13.0 instruction set summary .................................................................................................... ...................................................... 107 14.0 development support........................................................................................................ ....................................................... 109 15.0 electrical specifications.................................................................................................. .......................................................... 115 16.0 packaging information...................................................................................................... ........................................................ 137 appendix a: data sheet revision history........................................................................................ .................................................. 143 appendix b: migrating from other picmicro? devices ............................................................................. ......................................... 143 index .......................................................................................................................... ........................................................................ 145 on-line support................................................................................................................ ................................................................. 149 systems information and upgrade hot line ....................................................................................... ............................................... 149 reader response ................................................................................................................ .............................................................. 150 product identification system .................................................................................................. .......................................................... 151 to our valued customers it is our intention to provide our valued customers with the best documentation possible to ensure successful use of your micro chip products. to this end, we will continue to improve our publications to better suit your needs. our publications will be refined and enhanced as new volumes and updates are introduced. if you have any questions or comments regar ding this publication, please contact the marketing communications department via e-mail at docerrors@mail.microchip.com or fax the reader response form in the back of this data sheet to (480) 792-4150. we welcome your feedback. most current data sheet to obtain the most up-to-date version of this data s heet, please register at our worldwide web site at: http://www.microchip.com you can determine the version of a data sheet by examining its literature number found on the bottom outside corner of any page . the last character of the literature number is the vers ion number, (e.g., ds30000a is version a of document ds30000). errata an errata sheet, describing minor operational differences fr om the data sheet and recommended workarounds, may exist for curren t devices. as device/doc umentation issues become known to us, we will publis h an errata sheet. the errata will specify the revisi on of silicon and revision of document to which it applies. to determine if an errata sheet exists for a particul ar device, please check with one of the following:  microchip?s worldwide web site; http://www.microchip.com  your local microchip sales office (see last page)  the microchip corporate literatu re center; u.s. fax: (480) 792-7277 when contacting a sales office or the literature center, pleas e specify which device, revisi on of silicon and data sheet (inclu de liter- ature number) you are using. customer notification system register on our web site at www.microchip.com/cn to receive the most current information on all of our products.
PIC12F683 ds41211a-page 4 advance information ? 2003 microchip technology inc. notes:
? 2003 microchip technology inc. advance information ds41211a-page 5 PIC12F683 1.0 device overview this document contains device specific information for the PIC12F683. additional information may be found in the picmicro ? mid-range reference manual (ds33023), which may be obtained from your local microchip sales representative or downloaded from the microchip web site. the reference manual should be considered a complementary document to this data sheet and is highly recommended reading for a better understanding of the device architecture and operation of the peripheral modules. the PIC12F683 is covered by this data sheet. it is available in 8-pin pdip, soic and dfn-s packages. figure 1-1 shows a block diagram of the PIC12F683 device. table 1-1 shows the pinout description. figure 1-1: pic12f 683 block diagram flash program memory 13 data bus 8 14 program bus instruction reg program counter ram file registers direct addr 7 ram addr 9 addr mux indirect addr fsr reg status reg mux alu w reg instruction decode & control timing generation osc1/clkin osc2/clkout 8 8 8 3 8-level stack 128 2k x 14 bytes (13-bit) power-up timer oscillator start-up timer power-on reset watchdog timer mclr v ss brown-out detect 1 analog timer0 timer1 data eeprom 256 bytes eedata eeaddr gp0 gp1 gp2 gp3 gp4 gp5 comparator analog-to-digital converter an0 an1 an2 an3 cin- cin+ cout t0cki int t1cki configuration internal oscillator v ref and reference t1g v dd 8 timer2 ccp block ccp1
PIC12F683 ds41211a-page 6 advance information ? 2003 microchip technology inc. table 1-1: PIC12F683 pinout description name function input type output type description gp0/an0/cin+/icspdat gp0 ttl cmos gpio i/o w/ programmable pull-up, interrupt-on-change and ultra low-power wake-up an0 an ? a/d channel 0 input cin+ an ? comparator 1 input icspdat st cmos serial programming data i/o gp1/an1/cin-/v ref /icspclk gp1 ttl cmos gpio i/o w/pr ogrammable pull-up and interrupt-on- change an1 an ? a/d channel 1 input cin- an ? comparator 1 input v ref an ? external voltage reference for a/d icspclk st ? serial programming clock gp2/an2/t0cki/int/cout/ccp1 gp2 st cmos gpio i/o w/programmable pull-up and interrupt-on- change an2 an ? a/d channel 2 input t0cki st ? timer0 clock input int st ? external interrupt cout ? cmos comparator 1 output ccp1 st cmos capture input/compare output gp3/mclr /v pp gp3 ttl ? gpio input with interrupt-on-change mclr st ? master clear w/internal pull-up v pp hv ? programming voltage gp4/an3/t1g /osc2/clkout gp4 ttl cmos gpio i/o w/pr ogrammable pull-up and interrupt-on- change an3 an ? a/d channel 3 input t1g st ? timer1 gate osc2 ? xtal crystal/resonator clkout ? cmos f osc /4 output gp5/t1cki/osc1/clkin gp5 ttl cmos gpio i/o w/programmable pull-up and interrupt-on- change t1cki st ? timer1 clock osc1 xtal ? crystal/resonator clkin st ? external clock input/rc oscillator connection v ss v ss power ? ground reference v dd v dd power ? positive supply legend: ttl = ttl input buffer, st = schmitt trigger input buffer, an = analog input
? 2003 microchip technology inc. advance information ds41211a-page 7 PIC12F683 2.0 memory organization 2.1 program memory organization the PIC12F683 has a 13-bit program counter capable of addressing an 8k x 14 program memory space. only the first 2k x 14 (0000h - 07ffh) for the PIC12F683 is physically implemented. accessing a location above these boundaries will cause a wrap around within the first 2k x 14 space. the reset vector is at 0000h and the interrupt vector is at 0004h (see figure 2-1). figure 2-1: program memory map and stack for the PIC12F683 2.2 data memory organization the data memory (see figure 2-2) is partitioned into two banks, which contain the general purpose registers and the special function registers (sfr). the special function registers are located in the first 32 locations of each bank. register locations 20h-7fh in bank 0 and a0h-bfh in bank 1 are general purpose registers, implemented as static ram. register locations f0h- ffh in bank 1 point to addresses 70h-7fh in bank 0. all other ram is unimplemented and returns ? 0 ? when read. rp0 (status<5>) is the bank select bit. rp0 = ? 0 ? bank 0 is selected rp0 = ? 1 ? bank 1 is selected 2.2.1 general purpose register file the register file is organized as 128 x 8 in the PIC12F683. each register is accessed, either directly or indirectly, through the file select register fsr (see section 2.4 ?indirect addressing, indf and fsr registers? ). pc<12:0> 13 000h 0004 0005 07ffh 0800h 1fffh stack level 1 stack level 8 reset vector interrupt vector on-chip program memory call, return retfie, retlw stack level 2 note: the irp and rp1 bits status<7:6> are reserved and should always be maintained as ? 0 ?s.
PIC12F683 ds41211a-page 8 advance information ? 2003 microchip technology inc. 2.2.2 special function registers the special function registers are registers used by the cpu and peripheral functions for controlling the desired operation of the device (see table 2-1). these registers are static ram. the special registers can be classified into two sets: core and peripheral. the special function registers associated with the ?core? are described in this section. those related to the operation of the peripheral features are described in the section of that peripheral feature. figure 2-2: data memory map of the PIC12F683 indirect addr. (1) tmr0 pcl status fsr gpio pclath intcon pir1 tmr1l tmr1h t1con 00h 01h 02h 03h 04h 05h 06h 07h 08h 09h 0ah 0bh 0ch 0dh 0eh 0fh 10h 11h 12h 13h 14h 15h 16h 17h 18h 19h 1ah 1bh 1ch 1dh 1eh 1fh 20h 7fh bank 0 unimplemented data memory locations, read as '0'. note 1: not a physical register. cmcon0 vrcon general purpose registers 96 bytes eedat eeadr eecon2 (1) 70h file address file address wpu ioc indirect addr. (1) option_reg pcl status fsr trisio pclath intcon pie1 pcon 80h 81h 82h 83h 84h 85h 86h 87h 88h 89h 8ah 8bh 8ch 8dh 8eh 8fh 90h 91h 92h 93h 94h 95h 96h 97h 98h 99h 9ah 9bh 9ch 9dh 9eh 9fh a0h ffh bank 1 adresh adcon0 eecon1 adresl ansel bfh general purpose registers 32 bytes accesses 70h-7fh f0h tmr2 t2con ccpr1l ccpr1h ccp1con wdtcon cmcon1 osccon osctune pir2
? 2003 microchip technology inc. advance information ds41211a-page 9 PIC12F683 table 2-1: PIC12F683 special registers summary bank 0 addr name bit 7 bit 6 bit 5 bit 4 bit 3 bit 2 bit 1 bit 0 value on por, bod page bank 0 00h indf addressing this location uses contents of fsr to address data memory (not a physical register) xxxx xxxx 18,85 01h tmr0 timer0 module?s register xxxx xxxx 41,85 02h pcl program counter's (pc) least significant byte 0000 0000 17,85 03h status irp (1) rp1 (1) rp0 to pd zdcc 0001 1xxx 11,85 04h fsr indirect data memory address pointer xxxx xxxx 18,85 05h gpio ? ? i/o control registers --xx xxxx 33,85 06h ? unimplemented ? ? 07h ? unimplemented ? ? 08h ? unimplemented ? ? 09h ? unimplemented ? ? 0ah pclath ? ? ? write buffer for upper 5 bits of program counter ---0 0000 17,85 0bh intcon gie peie t0ie inte gpie t0if intf gpif 0000 0000 13,85 0ch pir1 eeif adif ccp1if ? cmif osfif tmr2if tmr1if 000- 0000 15,85 0dh ? unimplemented ? ? 0eh tmr1l holding register for the least significant byte of the 16-bit tmr1 xxxx xxxx 43,85 0fh tmr1h holding register for the most significant byte of the 16-bit tmr1 xxxx xxxx 43,85 10h t1con t1ginv t1ge t1ckps1 t1ckps0 t1oscen t1sync tmr1cs tmr1on 0000 0000 45,85 11h tmr2 timer2 module register 0000 0000 47,85 12h t2con ? toutps3 toutps2 toutps1 toutps0 tmr2on t2ckps1 t2ckps0 -000 0000 47,85 13h ccpr1l capture/compare/pwm register1 low byte xxxx xxxx 50,85 14h ccpr1h capture/compare/pwm register1 high byte xxxx xxxx 50,85 15h ccp1con ? ? dc1b1 dc1b0 ccp1m3 ccp1m2 ccp1m1 ccp1m0 --00 0000 49,84 16h ? unimplemented ? ? 17h ? unimplemented ? ? 18h wdtcon ? ? ? wdtps3 wdtps2 wdtps1 wdtps0 swdten ---0 1000 91,85 19h cmcon0 ?cout ? cinv cis cm2 cm1 cm0 -0-0 0000 55,85 1ah cmcon1 ? ? ? ? ? ? t1gss cmsync ---- --10 59,85 1bh ? unimplemented ? ? 1ch ? unimplemented ? ? 1dh ? unimplemented ? ? 1eh adresh most significant 8 bits of the left shift ed a/d result or 2 bits of right shifted result xxxx xxxx 65,85 1fh adcon0 adfm vcfg ? chs2 chs1 chs0 go/done adon 00-0 0000 66,85 legend: ? = unimplemented locations read as ? 0 ?, u = unchanged, x = unknown, q = value depends on condition shaded = unimplemented note 1: irp & rp1 bits are reserved, always maintain these bits clear.
PIC12F683 ds41211a-page 10 advance information ? 2003 microchip technology inc. table 2-2: PIC12F683 special function registers summary bank 1 addr name bit 7 bit 6 bit 5 bit 4 bit 3 bit 2 bit 1 bit 0 value on por, bod page bank 1 80h indf addressing this location uses contents of fsr to address data memory (not a physical register) xxxx xxxx 18,85 81h option_reg gpp u intedg t0cs t0se psa ps2 ps1 ps0 1111 1111 12,85 82h pcl program counter's (pc) least significant byte 0000 0000 17,85 83h status irp (1) rp1 (1) rp0 to pd zdcc 0001 1xxx 11,85 84h fsr indirect data memory address pointer xxxx xxxx 18,85 85h trisio ? ? trisio5 trisio4 trisio3 trisio2 trisio1 trisio0 --11 1111 34,85 86h ? unimplemented ? ? 87h ? unimplemented ? ? 88h ? unimplemented ? ? 89h ? unimplemented ? ? 8ah pclath ? ? ? write buffer for upper 5 bits of program counter ---0 0000 17,85 8bh intcon gie peie t0ie inte gpie t0if intf gpif 0000 0000 13,85 8ch pie1 eeie adie ccp1ie ? cmie osfie tmr2ie tmr1ie 000- 0000 14,85 8dh ? unimplemented ? ? 8eh pcon ? ? ulpwue sboden ? ?por bod --01 --qq 16,85 8fh osccon ? ircf2 ircf1 ircf0 osts (2) hts lts scs -110 x000 19,86 90h osctune ? ? ? tun4 tun3 tun2 tun1 tun0 ---0 0000 22,86 91h ? unimplemented ? ? 92h pr2 timer2 module period register 1111 1111 47,86 93h ? unimplemented ? ? 94h ? unimplemented ? ? 95h wpu (3) ? ? wpu5 wpu4 ? wpu2 wpu1 wpu0 --11 -111 34,86 96h ioc ? ? ioc5 ioc4 ioc3 ioc2 ioc1 ioc0 --00 0000 35,86 97h ? unimplemented ? ? 98h ? unimplemented ? ? 99h vrcon vren ?vrr ? vr3 vr2 vr1 vr0 0-0- 0000 62,86 9ah eedat eeprom data register 0000 0000 73,86 9bh eeadr eeprom address register 0000 0000 73,86 9ch eecon1 ? ? ? ? wrerr wren wr rd ---- x000 74,86 9dh eecon2 eeprom control register 2 (not a physical register) ---- ---- 74,86 9eh adresl least significant 2 bits of the left shifte d result or 8 bits of the right shifted result xxxx xxxx 65,86 9fh ansel ? adcs2 adcs1 adcs0 ans3 ans2 ans1 ans0 -000 1111 67,86 legend: ? = unimplemented locations read as ? 0 ?, u = unchanged, x = unknown, q = value depends on condition, shaded = unimplemented note 1: irp & rp1 bits are reserved, always maintain these bits clear. 2: osccon bit reset to ? 0 ? with dual speed start-up and lp, hs, or xt selected as the oscillator. 3: gp3 pull-up is enabled when mclre is ? 1 ? in configuration word.
? 2003 microchip technology inc. advance information ds41211a-page 11 PIC12F683 2.2.2.1 status register the status register, shown in register 2-1, contains:  arithmetic status of the alu  reset status  bank select bits for data memory (sram) the status register can be the destination for any instruction, like any other register. if the status register is the destination for an instruction that affects the z, dc or c bits, then the write to these three bits is disabled. these bits are set or cleared according to the device logic. furthermore, the to and pd bits are not writable. therefore, the result of an instruction with the status register as destination may be different than intended. for example, clrf status will clear the upper three bits and set the z bit. this leaves the status register as 000u u1uu (where u = unchanged). it is recommended, therefore, that only bcf, bsf, swapf and movwf instructions are used to alter the status register, because these instructions do not affect any status bits. for other instructions not affect- ing any status bits, see the ?instruction set summary?. register 2-1: status ? status register (address: 03h or 83h) note 1: bits irp and rp1 (status<7:6>) are not used by the PIC12F683 and should be maintained as clear. use of these bits is not recommended, since this may affect upward compatibility with future products. 2: the c and dc bits operate as a borrow and digit borrow out bit, respectively, in subtraction. see the sublw and subwf instructions for examples. reserved reserved r/w-0 r-1 r-1 r/w-x r/w-x r/w-x irp rp1 rp0 to pd zdcc bit 7 bit 0 bit 7 irp: this bit is reserved and should be maintained as ? 0 ? bit 6 rp1: this bit is reserved and should be maintained as ? 0 ? bit 5 rp0: register bank select bit (used for direct addressing) 1 = bank 1 (80h - ffh) 0 = bank 0 (00h - 7fh) bit 4 to : time-out bit 1 = after power-up, clrwdt instruction, or sleep instruction 0 = a wdt time-out occurred bit 3 pd : power-down bit 1 = after power-up or by the clrwdt instruction 0 = by execution of the sleep instruction bit 2 z : zero bit 1 = the result of an arithmetic or logic operation is zero 0 = the result of an arithmetic or logic operation is not zero bit 1 dc : digit carry/borrow bit ( addwf , addlw,sublw,subwf instructions) for borrow, the polarity is reversed. 1 = a carry-out from the 4th low-order bit of the result occurred 0 = no carry-out from the 4th low-order bit of the result bit 0 c : carry/borrow bit ( addwf , addlw, sublw, subwf instructions) 1 = a carry-out from the most significant bit of the result occurred 0 = no carry-out from the most significant bit of the result occurred note 1: for borrow the polarity is reversed. a subtraction is executed by adding the two?s complement of the second operand. for rotate ( rrf , rlf ) instructions, this bit is loaded with either the high or low-order bit of the source register. legend: r = readable bit w = writable bit u = unimplemented bit, read as ?0? - n = value at por ?1? = bit is set ?0? = bit is cleared x = bit is unknown
PIC12F683 ds41211a-page 12 advance information ? 2003 microchip technology inc. 2.2.2.2 option register the option register is a readable and writable register, which contains various control bits to configure:  tmr0/wdt prescaler  external gp2/int interrupt tmr0  weak pull-ups on gpio register 2-2: option_reg ? option register (address: 81h) note: to achieve a 1:1 prescaler assignment for tmr0, assign the prescaler to the wdt by setting psa bit to ? 1 ? (option<3>). see section 5.4 ?prescaler? . r/w-1 r/w-1 r/w-1 r/w-1 r/w-1 r/w-1 r/w-1 r/w-1 gpp u intedg t0cs t0se psa ps2 ps1 ps0 bit 7 bit 0 bit 7 gppu : gpio pull-up enable bit 1 = gpio pull-ups are disabled 0 = gpio pull-ups are enabled by individual port latch values in wpu register bit 6 intedg: interrupt edge select bit 1 = interrupt on rising edge of gp2/int pin 0 = interrupt on falling edge of gp2/int pin bit 5 t0cs: tmr0 clock source select bit 1 = transition on gp2/t0cki pin 0 = internal instruction cycle clock (clkout) bit 4 t0se: tmr0 source edge select bit 1 = increment on high-to-low transition on gp2/t0cki pin 0 = increment on low-to-high transition on gp2/t0cki pin bit 3 psa: prescaler assignment bit 1 = prescaler is assigned to the wdt 0 = prescaler is assigned to the timer0 module bit 2-0 ps2:ps0: prescaler rate select bits note 1: a dedicated 16-bit wdt postscaler is available for the PIC12F683. see section 12.6 ?watchdog timer (wdt)? for more information. legend: r = readable bit w = writable bit u = unimplemented bit, read as ?0? - n = value at por ?1? = bit is set ?0? = bit is cleared x = bit is unknown 000 001 010 011 100 101 110 111 1 : 2 1 : 4 1 : 8 1 : 16 1 : 32 1 : 64 1 : 128 1 : 256 1 : 1 1 : 2 1 : 4 1 : 8 1 : 16 1 : 32 1 : 64 1 : 128 bit value tmr0 rate wdt rate (1)
? 2003 microchip technology inc. advance information ds41211a-page 13 PIC12F683 2.2.2.3 intcon register the intcon register is a readable and writable register, which contains the various enable and flag bits for tmr0 register overflow, gpio change and external gp2/int pin interrupts. register 2-3: intcon ? interrupt control register (address: 0bh or 8bh) note: interrupt flag bits are set when an interrupt condition occurs, regardless of the state of its corresponding enable bit or the global enable bit, gie (intcon<7>). user software should ensure the appropriate interrupt flag bits are clear prior to enabling an interrupt. r/w-0 r/w-0 r/w-0 r/w-0 r/w-0 r/w-0 r/w-0 r/w-0 gie peie t0ie inte gpie t0if intf gpif bit 7 bit 0 bit 7 gie: global interrupt enable bit 1 = enables all unmasked interrupts 0 = disables all interrupts bit 6 peie: peripheral interrupt enable bit 1 = enables all unmasked peripheral interrupts 0 = disables all peripheral interrupts bit 5 t0ie: tmr0 overflow interrupt enable bit 1 = enables the tmr0 interrupt 0 = disables the tmr0 interrupt bit 4 inte: gp2/int external interrupt enable bit 1 = enables the gp2/int external interrupt 0 = disables the gp2/int external interrupt bit 3 gpie: gpio change interrupt enable bit (1) 1 = enables the gpio change interrupt 0 = disables the gpio change interrupt bit 2 t0if: tmr0 overflow interrupt flag bit (2) 1 = tmr0 register has overflowed (must be cleared in software) 0 = tmr0 register did not overflow bit 1 intf: gp2/int external interrupt flag bit 1 = the gp2/int external interrupt occurred (must be cleared in software) 0 = the gp2/int external interrupt did not occur bit 0 gpif: gpio change interrupt flag bit 1 = when at least one of the gpio<5:0> pins changed state (must be cleared in software) 0 = none of the gpio<5:0> pins have changed state note 1: ioc register must also be enabled. 2: t0if bit is set when timer0 rolls over. timer0 is unchanged on reset and should be initialized before clearing t0if bit. legend: r = readable bit w = writable bit u = unimplemented bit, read as ?0? - n = value at por ?1? = bit is set ?0? = bit is cleared x = bit is unknown
PIC12F683 ds41211a-page 14 advance information ? 2003 microchip technology inc. 2.2.2.4 pie1 register the pie1 register contains the interrupt enable bits, as shown in register 2-4. register 2-4: pie1 ? peripheral interrupt enable register 1 (address: 8ch) note: bit peie (intcon<6>) must be set to enable any peripheral interrupt. r/w-0 r/w-0 r/w-0 u-0 r/w-0 r/w-0 r/w-0 r/w-0 eeie adie ccp1ie ? cmie osfie tmr2ie tmr1ie bit 7 bit 0 bit 7 eeie: ee write complete interrupt enable bit 1 = enables the ee write complete interrupt 0 = disables the ee write complete interrupt bit 6 adie: a/d converter interrupt enable bit 1 = enables the a/d converter interrupt 0 = disables the a/d converter interrupt bit 5 ccp1ie: ccp1 interrupt enable bit 1 = enables the ccp1 interrupt 0 = disables the ccp1 interrupt bit 4 unimplemented: read as ?0? bit 3 cmie: comparator interrupt enable bit 1 = enables the comparator 1 interrupt 0 = disables the comparator 1 interrupt bit 2 osfie: oscillator fail interrupt enable bit 1 = enables the oscillator fail interrupt 0 = disables the oscillator fail interrupt bit 1 tmr2ie: timer 2 to pr2 match interrupt enable bit 1 = enables the timer 2 to pr2 match interrupt 0 = disables the timer 2 to pr2 match interrupt bit 0 tmr1ie: timer 1 overflow interrupt enable bit 1 = enables the timer 1 overflow interrupt 0 = disables the timer 1 overflow interrupt legend: r = readable bit w = writable bit u = unimplemented bit, read as ?0? - n = value at por ?1? = bit is set ?0? = bit is cleared x = bit is unknown
? 2003 microchip technology inc. advance information ds41211a-page 15 PIC12F683 2.2.2.5 pir1 register the pir1 register contains the interrupt flag bits, as shown in register 2-5. register 2-5: pir1 ? peripheral interrupt register 1 (address: 0ch) note: interrupt flag bits are set when an interrupt condition occurs, regardless of the state of its corresponding enable bit or the global enable bit, gie (intcon<7>). user software should ensure the appropriate interrupt flag bits are clear prior to enabling an interrupt. r/w-0 r/w-0 r/w-0 u-0 r/w-0 r/w-0 r/w-0 r/w-0 eeif adif ccp1if ? cmif osfif tmr2if tmr1if bit 7 bit 0 bit 7 eeif : eeprom write operation interrupt flag bit 1 = the write operation completed (must be cleared in software) 0 = the write operation has not completed or has not been started bit 6 adif : a/d interrupt flag bit 1 = a/d conversion complete 0 = a/d conversion has not completed or has not been started bit 5 ccp1if: ccp1 interrupt flag bit capture mod e: 1 = a tmr1 register capture occurred (must be cleared in software) 0 = no tmr1 register capture occurred compare mode : 1 = a tmr1 register compare match occurred (must be cleared in software) 0 = no tmr1 register compare match occurred pwm mode : unused in this mode bit 4 unimplemented: read as ?0? bit 3 cmif : comparator interrupt flag bit 1 = comparator 1 output has changed (must be cleared in software) 0 = comparator 1 output has not changed bit 2 osfif : oscillator fail interrupt flag bit 1 = system oscillator failed, clock input has changed to intosc (must be cleared in software) 0 = system clock operating bit 1 tmr2if : timer 2 to pr2 match interrupt flag bit 1 = timer 2 to pr2 match occurred (must be cleared in software) 0 = timer 2 to pr2 match has not occurred bit 0 tmr1if : timer 1 overflow interrupt flag bit 1 = timer 1 register overflowed (must be cleared in software) 0 = timer 1 has not overflowed legend: r = readable bit w = writable bit u = unimplemented bit, read as ?0? - n = value at por ?1? = bit is set ?0? = bit is cleared x = bit is unknown
PIC12F683 ds41211a-page 16 advance information ? 2003 microchip technology inc. 2.2.2.6 pcon register the power control (pcon) register contains flag bits (see table 12-2) to differentiate between a:  power-on reset (por)  brown-out detect (bod)  watchdog timer reset (wdt)  external mclr reset the pcon register also controls the ultra low-power wake-up and software enable of the bod. the pcon register bits are shown in register 2-6. register 2-6: pcon ? power control register (address: 8eh) u-0 u-0 r/w-0 r/w-1 u-0 u-0 r/w-0 r/w-x ? ? ulpwue sboden ? ?por bod bit 7 bit 0 bit 7-6 unimplemented: read as ? 0 ? bit 5 ulpwue : ultra low-power wake-up enable bit 1 = ultra low-power wake-up enabled 0 = ultra low-power wake-up disabled bit 4 sboden : software bod enable bit (1) 1 = bod enabled 0 = bod disabled bit 3-2 unimplemented: read as ?0? bit 1 por : power-on reset status bit 1 = no power-on reset occurred 0 = a power-on reset occurred (must be set in software after a power-on reset occurs) bit 0 bod : brown-out detect status bit 1 = no brown-out detect occurred 0 = a brown-out detect occurred (must be set in software after a brown-out detect occurs) note 1: boden<1:0> = ? 01 ? in configuration word for this bit to control the bod. legend: r = readable bit w = writable bit u = unimplemented bit, read as ?0? - n = value at por ?1? = bit is set ?0? = bit is cleared x = bit is unknown
? 2003 microchip technology inc. advance information ds41211a-page 17 PIC12F683 2.3 pcl and pclath the program counter (pc) is 13-bits wide. the low byte comes from the pcl register, which is a readable and writable register. the high byte (pc<12:8>) is not directly readable or writable and comes from pclath. on any reset, the pc is cleared. figure 2-3 shows the two situations for the loading of the pc. the upper example in figure 2-3 shows how the pc is loaded on a write to pcl (pclath<4:0>  pch). the lower example in figure 2-3 shows how the pc is loaded during a call or goto instruction (pclath<4:3>  pch). figure 2-3: loading of pc in different situations 2.3.1 computed goto a computed goto is accomplished by adding an offset to the program counter ( addwf pcl ). when perform- ing a table read using a computed goto method, care should be exercised if the table location crosses a pcl memory boundary (each 256-byte block). refer to the application note ?implementing a table read? (an556). 2.3.2 stack the PIC12F683 family has an 8-level x 13-bit wide hardware stack (see figure 2-1). the stack space is not part of either program or data space and the stack pointer is not readable or writable. the pc is pushed onto the stack when a call instruction is executed or an interrupt causes a branch. the stack is poped in the event of a return, retlw or a retfie instruction execution. pclath is not affected by a push or pop operation. the stack operates as a circular buffer. this means that after the stack has been pushed eight times, the ninth push overwrites the value that was stored from the first push. the tenth push overwrites the second push (and so on). pc 12 8 7 0 5 pclath<4:0> pclath instruction with alu result goto, call opcode <10:0 > 8 pc 12 11 10 0 11 pclath<4:3> pch pcl 87 2 pclath pch pcl pcl as destination note 1: there are no status bits to indicate stack overflow or stack underflow conditions. 2: there are no instructions/mnemonics called push or pop. these are actions that occur from the execution of the call, return, retlw and retfie instructions or the vectoring to an interrupt address.
PIC12F683 ds41211a-page 18 advance information ? 2003 microchip technology inc. 2.4 indirect addressing, indf and fsr registers the indf register is not a physical register. addressing the indf register will cause indirect addressing. indirect addressing is possible by using the indf register. any instruction using the indf register actually accesses data pointed to by the file select register (fsr). reading indf itself indirectly will produce 00h. writing to the indf register indirectly results in a no operation (although status bits may be affected). an effective 9-bit address is obtained by concatenating the 8-bit fsr register and the irp bit (status<7>), as shown in figure 2-4. a simple program to clear ram location 20h-2fh using indirect addressing is shown in example 2-1. example 2-1: indirect addressing figure 2-4: direct/indirect addressing PIC12F683 movlw 0x20 ;initialize pointer movwf fsr ;to ram next clrf indf ;clear indf register incf fsr ;inc pointer btfss fsr,4 ;all done? goto next ;no clear next continue ;yes continue for memory map detail see figure 2-2. note 1: the rp1 and irp bits are reserved; always maintain these bits clear. data memory indirect addressing direct addressing bank select location select rp1 (1) rp0 6 0 from opcode irp (1) fsr register 7 0 bank select location select 00 01 10 11 180h 1ffh 00h 7fh bank 0 bank 1 bank 2 bank 3 not used
? 2003 microchip technology inc. advance information ds41211a-page 19 PIC12F683 3.0 oscillator configurations 3.1 oscillator types the PIC12F683 can be operated in eight different oscillator modes. the user can program three configuration bits (fosc2:fosc0) to select one of these eight modes: 1. lp - low-power crystal 2. xt - crystal/resonator 3. hs - high-speed crystal/resonator 4. rc - external resistor/capacitor with f osc /4 output on gp4 5. rcio - external resistor/capacitor with i/o on gp4 6. intosc - internal oscillator with f osc /4 output on gp4 and i/o on gp5 7. intoscio - internal oscillator with i/o on gp4 and gp5 8. ec - external clock with i/o on gp4 3.2 crystal oscillator/ceramic resonators in xt, lp or hs modes, a crystal or ceramic resonator is connected to the osc1/clki and osc2/clko pins to establish oscillation (see figure 3-1 and figure 3-2). the PIC12F683 oscillator design requires the use of a parallel cut crystal. use of a series cut crystal may give a frequency out of the crystal manufacturers specifications. figure 3-1: crystal operation (hs, xt, or lp osc. configuration) table 3-1: capacitor selection for crystal oscillator (for design guidance only) note 1: see table 3-1 for typical values of c1 and c2. 2: a series resistor (r s ) may be required for at strip cut crystals. 3: r f varies with the crystal chosen (typically between 2 m  to 10 m ) . c1 (1) c2 (1) xtal osc2 r s (2) osc1 r f (3) sleep to internal logic PIC12F683 osc. type crystal freq. typical capacitor values tested c1 c2 lp 32 khz 33 pf 33 pf xt 200 khz 56 pf 56 pf 1 mhz 15 pf 15 pf 4 mhz 15 pf 15 pf hs 4 mhz 15 pf 15 pf 8 mhz 15 pf 15 pf 20 mhz 15 pf 15 pf capacitor values are for design guidance only. different capacitor values may be required to produce acceptable oscillator operation. the user should test the performance of the oscillator over the expected v dd and temperature range for the application. see the notes following this table for additional information. note 1: higher capacitance increases the stability of oscillator, but also increases the start-up time. 2: since each crystal has its own character- istics, the user should consult the crystal manufacturer for appropriate values of external components. 3: rs may be required in hs mode, as well as xt mode, to avoid overdriving crystals with low drive level specification. 4: always verify oscillator performance over the v dd and temperature range that is expected for the application.
PIC12F683 ds41211a-page 20 advance information ? 2003 microchip technology inc. figure 3-2: ceramic resonator operation (hs or xt osc. configuration) table 3-2: ceramic resonators (for design guidance only) 3.3 external clock input the ec oscillator mode requires an external clock source to be connected to the osc1 pin. there is no oscillator start-up time required after a power-on reset, or after an exit from sleep mode. in the ec oscillator mode, the osc2 pin becomes an additional general purpose i/o pin. the i/o pin becomes bit 4 of gpio (gp4). figure 3-3 shows the pin connections for the ec oscillator mode. figure 3-3: external clock input operation (ec configuration) 3.4 rc oscillator for timing insensitive applications, the ?rc? and ?rcio? device options offer additional cost savings. the rc oscillator frequency is a function of the supply voltage, the resistor (r ext ) and capacitor (c ext ) values and the operating temperature. in addition to this, the oscillator frequency will vary from unit to unit due to normal manufacturing variation. furthermore, the difference in lead frame capacitance between pack- age types will also affect the oscillation frequency, especially for low c ext values. the user also needs to take into account variation due to tolerance of external r and c components used. figure 3-4 shows how the r/c combination is connected. in the rc oscillator mode, the oscillator frequency divided by 4 is available on the osc2 pin. this signal may be used for test purposes or to synchronize other logic. figure 3-4: rc oscillator mode the rcio oscillator mode (figure 3-5) functions like the rc mode, except that the osc2 pin becomes an additional general purpose i/o pin. the i/o pin becomes bit 4 of gpio (gp4). figure 3-5: rcio oscillator mode typical capacitor values used: mode freq osc1 osc2 xt 455 khz 2.0 mhz 4.0 mhz 56 pf 47 pf 33 pf 56 pf 47 pf 33 pf hs 8.0 mhz 16.0 mhz 27 pf 22 pf 27 pf 22 pf capacitor values are for design guidance only. different capacitor values may be required to produce acceptable oscillator operation. the user should test the performance of the oscillator over the expected v dd and temperature range for the application. note 1: see table 3-2 for typical values of c1 and c2. 2: a series resistor (r s ) may be required. 3: r f varies with the resonator chosen (typically between 2 m  to 10 m ) . c1 (1) c2 (1) res osc2 r s (2) osc1 r f (3) sleep to internal logic PIC12F683 osc1/clkin i/o (osc2) gp4 clock from ext. system PIC12F683 osc2/clkout c ext r ext PIC12F683 osc1 f osc /4 internal clock v dd v ss recommended values: 3 k   r ext  100 k  c ext > 20 pf c ext r ext PIC12F683 osc1 internal clock v dd v ss recommended values: 3 k   r ext  100 k  c ext > 20 pf i/o (osc2) gp4
? 2003 microchip technology inc. advance information ds41211a-page 21 PIC12F683 3.5 internal oscillator block the PIC12F683 includes an oscillator block with two independent internal oscillators; a calibrated intosc (8 mhz) and an uncalibrated intrc (31 khz). the 8 mhz intosc also drives the intosc postscaler, which can provide a range of six clock frequencies from 125 khz to 4 mhz. therefore, the oscillator block can provide the following frequencies as the system clock: 31 khz, 125 khz, 256 khz, 512 khz, 1 mhz, 2 mhz, 4 mhz and 8 mhz. the intrc (31 khz) oscillator is enabled by selecting the intrc as the system clock source, or when any of the following are enabled:  power-up timer (pwrt)  watchdog timer (wdt)  two-speed start-up (if ircf = ? 000 ?).  fail-safe clock monitor (fscm) the intosc (8 mhz) oscillator is enabled by selecting the intosc as the system clock source, or when two-speed start-up is enabled, if ircf  ? 000 ?. these features are discussed in greater detail in section 12.0 ?special features of the cpu? . the clock source frequency (intosc direct, intrc direct, or intosc postscaler) is selected by configuring the ircf bits of the osccon register. 3.5.1 intosc modes using the internal oscillator as the clock source can eliminate the need for up to two external oscillator pins, after which it can be used for digital i/o. two distinct configurations are available:  in intosc mode, the osc2 pin outputs f osc /4, while osc1 functions as gp5 for digital input and output.  in intoscio mode, osc1 functions as gp5 and osc2 functions as gp4, both for digital input and output. 3.5.2 intosc calibration the PIC12F683 has two internal oscillators. the 8 mhz intosc and a 31 khz intrc oscillator. the 8 mhz intosc is factory calibrated. see section 15.0 ?elec- trical specifications? , for information on variation over voltage and temperature. the 31 khz intrc is uncalibrated. the PIC12F683 stores the intosc calibration values in fuses located in the calibration word (2008h). the calibration word is not erased using the specified bulk erase sequence in the PIC12F683 programming specification and does not require reprogramming. 3.5.3 osctune register the internal oscillator?s output has been calibrated at the factory, but can be adjusted in the application. this is done by writing to the osctune register (register 3-1). the osctune register has a tuning range of 12%. due to process variation, the monotonicity and frequency step can not be specified. when the osctune register is modified, the intosc frequency will begin shifting to the new frequency. osctune does not affect the intrc frequency. the intosc clock will stabilize within 1 ms. code execution continues during this shift. there is no indication that the shift has occurred. operation of features that depend on the 31 khz intrc clock source frequency, such as the wdt, fail-safe clock monitor and peripherals, will not be affected by the change in frequency. note: throughout this data sheet, when referring specifically to a generic clock source, the term ?intosc? may also be used to refer to the clock modes using the internal oscillator block. this is regardless of whether the actual frequency used is intosc (8 mhz), the intosc postscaler (4 mhz to 125 khz) or intrc (31 khz). note: address 2008h is beyond the user program memory space. it belongs to the special configuration memory space (2000h - 3fffh), which can be accessed only during programming. see PIC12F683 program- ming specification for more information.
PIC12F683 ds41211a-page 22 advance information ? 2003 microchip technology inc. register 3-1: osctune ? oscillator tuning register (address 90h) 3.6 clock sources and oscillator switching the PIC12F683 includes a feature that allows the system clock source to be switched between the main oscillator and the internal clock source. essentially, there are two clock sources for this device:  primary oscillators  secondary oscillator (i.e., internal oscillator block intosc and intrc) the primary oscillators include the external crystal and resonator modes, the external rc modes, the external clock mode and the internal oscillator block. the mode is defined on por by the contents of configuration word. the clock sources for the PIC12F683 are shown in figure 3-6. see section 12.0 ?special features of the cpu? for configuration word details. the secondary oscillator is the internal oscillator block which is comprised of two independent internal oscillators; an uncalibrated 31 khz intrc and a calibrated 8 mhz intosc with a dedicated postscaler. 3.6.1 osccon register the osccon register (register 3-2) controls several aspects of the system clock?s operation. the system clock select bit, scs (osccon<0>), selects the clock source that is used. when the bit is cleared, the system clock source comes from the primary oscillator selected by the fosc2:fosc0 bits in configuration word. when the bit is set, the system clock source is provided by the internal oscillator block. after a reset, scs is always cleared. any automatic clock switch which may occur from two-speed start-up or fail-safe clock monitor does not update the scs bit. the user can monitor the osts (osccon<3>) to determine the current system clock source. the internal oscillator select bits ircf2:ircf0 (osccon<6:4>) select the frequency output of the internal oscillator block that is used to drive the system clock. the choices are the intrc source (31 khz), the intosc source (8 mhz), or one of the six frequencies derived from the intosc postscaler (125 khz to 4mhz). the osts, hts (osccon<2>) and lts (osccon<1>) bits indicate the status of the primary oscillator, 8 mhz intosc and 31 khz intrc; these bits are set when their respective oscillators are stable. in particular, osts indicates that the oscillator start-up timer has timed out. u-0 u-0 u-0 r/w-0 r/w-0 r/w-0 r/w-0 r/w-0 ? ? ? tun4 tun3 tun2 tun1 tun0 bit 7 bit 0 bit 7-5 unimplemented: read as ? 0 ? bit 4-0 tun<4:0>: frequency tuning bits 01111 = maximum frequency 01110 =    00001 = 00000 = center frequency. oscillator module is running at the calibrated frequency. 11111 =    10000 = minimum frequency legend: r = readable bit w = writable bit u = unimplemented bit, read as ?0? -n = value at por ?1? = bit is set ?0? = bit is cleared x = bit is unknown note: the PIC12F683 uses a factory calibrated 8 mhz internal oscillator (intosc) and postscaler to provide the 125 khz to 8 mhz system clock frequencies. note: following any reset, the ircf bits are set to ?110? and the frequency selection is forced to 4 mhz. the user can modify the ircf bits to select a different frequency.
?
PIC12F683 ds41211a-page 24 advance information ? 2003 microchip technology inc. 3.6.2 clock switching clock switching will occur for the following reasons:  the fail-safe clock monitor is enabled, the device is running from the primary oscillator (i.e., the oscillator defined by the fosc<2:0>), and the primary oscillator fails. the clock source will switch to the secondary clock source, intosc.  a wake-up due to a reset or a por, and the device is configured for two-speed start-up or fail-safe clock monitor. the device will switch from the secondary clock source to the primary after it has stabilized.  a wake-up from sleep occurs due to an interrupt or wdt wake-up, two-speed start-up or fail-safe clock monitor is enabled, the primary clock is xt, hs, or lp and the scs (osccon<0>) is clear. the clock will switch from the secondary to the primary system clock after the oscillator start-up timer expires in 1024 clocks.  scs bit is modified by the user or a reset.  ircf bits are modified by the user or a reset. for more information, see section 12.6.3 ?two-speed clock start-up mode? and section 12.6.4 ?fail-safe clock monitor? . 3.6.3 clock transition and wdt when clock switching is performed and the primary oscillator is xt, hs or lp, the watchdog timer is not available while the oscillator start-up timer is active (1024 clocks). this is due to the watchdog timer and oscillator start-up timer sharing the same ripple counter. once the clock transition is complete, the watchdog counter is re-enabled with the counter reset. this allows the user to synchronize the watchdog timer to the start of execution at the new clock frequency. note: clock switching will not occur if the primary system clock is already configured as intosc.
? 2003 microchip technology inc. advance information ds41211a-page 25 PIC12F683 figure 3-6: pic12f 683 clock diagram 3.6.4 modifying the ircf bits the ircf bits can be modified at any time, regardless of which clock source is currently being used, as the system clock. the internal oscillator allows users to change the frequency during run time. this is achieved by modifying the ircf bits in the osccon register. the sequence of events that occur after the ircf bits are modified is dependent upon the initial and final value of the ircf bits. 3.6.4.1 switch from 31 khz up to 125 khz to 8mhz if the intrc (ircf<2:0> = 000 ) is running and the intosc (ircf<2:0>  000) is selected, a 5 s clock switch delay is enabled before the hts bit will be set. this delay allows the intosc to start and stabilize. the switch will occur on the next falling edge after the timer expires. if the wdt and fail-safe clock monitor are disabled, the intrc will be disabled to conserve power and the lts bit (osccon<1>) is cleared. time sensitive code should wait for the hts bit (osccon<2>) to become set before continuing. this bit can be monitored to ensure that the frequency is stable before using the system clock in time critical applications. 3.6.4.2 switch from 125 khz to 8 mhz down to 31 khz if the intosc (ircf<2:0>  000) is running and intrc (ircf<2:0> = 000 ) is requested, the 5 s delay is enabled before the lts bit will be set indicating the intrc is stable. the switch will occur on the next falling edge after the timer expires. the delay will not occur if the fail-safe clock monitor or wdt are enabled for the intrc will already be active. the intosc is disabled to conserve power and the hts bit is cleared. 3.6.4.3 switch within 125 khz to 8 mhz if a different intosc frequency is selected, there is no need for a 5 s delay. the new intosc frequency will already be stable and the switch will occur on the next falling edge of the new frequency. 3.6.5 clock transition sequence the following sequence is performed when the ircf bits are changed and the system clock is the internal oscillator. 1. the ircf bits are modified. 2. the clock switching circuitry waits for a falling edge of the current clock, at which point clkout is held low. 3. the clock switching circuitry then waits for the next falling edge of the requested clock, after which it switches to this new clock source and updates the hts/lts bit as appropriate. 4. oscillator switchover is complete. osc1 osc2 sleep primary oscillator lp, xt, hs, rc, ec cpu peripherals postscaler mux mux 8 mhz 4 mhz 2 mhz 1 mhz 500 khz 125 khz 250 khz osccon<6:4> 111 110 101 100 011 010 001 000 31 khz 31 khz source internal oscillator block power-up timer, wdt, fail-safe clock monitor internal oscillator intrc intosc fosc2:fosc0, scs 8 mhz source note: caution must be taken when modifying the ircf bits using bcf or bsf instructions. it is possible to modify the ircf bits to a fre- quency that may be out of the v dd specifi- cation range; for example, v dd = 2.0v and ircf = 111 (8 mhz).
PIC12F683 ds41211a-page 26 advance information ? 2003 microchip technology inc. 3.6.6 oscillator delay upon power-up and wake-up the oscillator start-up timer (ost) is used to ensure that a stable system clock is provided to the device. the ost is activated following a por or a wake-up from sleep mode and the system clock is configured for lp, xt, or hs. table 3-3 shows examples where the oscillator delay is invoked. table 3-3: oscillator delay examples switch from switch to frequency oscillator delay comments sleep/por intrc intosc 31 khz 125khz - 8mhz 5 s-10 s (approx.) cpu start-up (1) following a wake-up from sleep mode or por, cpu start-up is invoked to allow the cpu to become ready for code execution. sleep ec, rc dc - 20 mhz intrc (31 khz) ec, rc dc - 20 mhz sleep/por lp, xt, hs 31 khz - 20 mhz 1024 clock cycles (ost) intrc (31 khz) intosc 125khz - 8mhz 1 s (approx.) refer to section 3.6.4 ?modifying the ircf bits? for further details. note 1: the 5 s-10 s start-up delay is based on a 1 mhz system clock.
? 2003 microchip technology inc. advance information ds41211a-page 27 PIC12F683 3.6.7 primary to secondary oscillator switch when scs bit (osccon<0>) is cleared, a clock transition is generated if the system clock is not already using the intosc. the event will clear the osts bit, switch the system clock from the primary system clock as determined by fosc<2:0> in the configuration word, to the secondary clock, intosc, and shut down the primary system clock to conserve power. after the scs bit is changed, the frequency may not be stable immediately. the appropriate hts/lts bit will be set when the intosc/intrc is stable, after approxi- mately 1 s. there will not be a delay if the device switches to the intrc (31 khz) and the fail-safe clock monitor or wdt is enabled. after a clock switch has been executed, the osts bit is cleared, indicating a low-power mode, and the device does not run from the primary system clock. the internal q clocks are held in the q1 state until next falling edge after the intosc is stable. after the delay, the clock input to the q clocks is released and operation resumes (see figure 3-7). figure 3-7: primary (xt, hs, lp, ec, extrc) to secondary oscillator switch q1 q2 q3 q4 q1 q2 q3 q4 q1 q2 q3 q4 q1 pc pc + 1 pc + 2 pc + 3 t dly t scs t int t osc osc1 intosc system_clock scs program note 1: t int = 32 s maximum. 2: t osc = 50 ns minimum. 3: t scs = 1 t int . 4: t dly = 1 t int . counter
PIC12F683 ds41211a-page 28 advance information ? 2003 microchip technology inc. 3.6.8 secondary to primary oscillator switch when switching from the secondary back to the primary system clock by clearing the scs bit (osccon<0>), the sequence of events that take place will depend upon the value of the f osc bits in the configuration word. if the primary clock source is configured as a crystal (hs, xt, or lp), then the transition will take place after 1024 clock cycles. this allows time for the crystal oscillator to power-up and stabilize prior to the switchover. during the oscillator start-up time, the system clock comes from the secondary clock source, intosc. the osts bit (osccon<3>) can be monitored to indicate when the switchover is complete. following the oscillator start-up time, the internal q clocks are held in the q1 state until next falling edge clock of the primary system clock. the clock input to the q clocks is then released, and operation resumes with primary system clock determined by the f osc bits (see figure 3-8). 3.6.8.1 returning to primary oscillator source sequence changing from secondary to primary clock source can be accomplished by clearing the scs bit. this is the sequence of events that follows: 1. if the primary system clock is configured as ec or rc, then the ost time-out is skipped. skip to step 3. 2. if the primary system clock is configured as an external oscillator (hs, xt, lp), then the ost will be active, waiting for 1024 clocks of the primary system clock. the device will use the intosc as the system clock during this time. 3. on the following q1, the device holds the system clock in q1. 4. the device stays in q1 until the next falling edge of the primary system clock. 5. once the switch over is complete, the device begins to run from the primary oscillator. 6. if the intosc or intrc is not required, the unused oscillator will be shut down to save current. the intrc will not be disabled if it is being used for any other function, such as wdt, or fail-safe clock monitoring. figure 3-8: secondary to primary oscillator (xt, lp or hs) switch note: if the primary system clock is either rc or ec, an internal delay timer (5-10 s) will suspend operation after exiting secondary oscillator mode to allow the cpu to stabilize prior to code execution. q1 q2 q3 q4 q1 q2 q3 q4 q1 0 1 1022 1023 pc pc + 1 pc + 2 t t scs t osc t t ost t t int t intosc osc1 osc2 scs program system clock note 1: t int = 32 s maximum. 2: t osc = 50 ns minimum. 3: t scs = 1 t int . counter
? 2003 microchip technology inc. advance information ds41211a-page 29 PIC12F683 3.6.8.2 returning to primary oscillator with a reset a reset will clear scs bit. the sequence for starting the primary oscillator following a reset is the same for all forms of reset including por. there is no transition sequence from the secondary to the primary oscillator. instead, the device will reset the state of the osccon register and default to the primary oscillator. the sequence of events that take place after this will depend upon the value of the f osc bits in the configuration register. if the external oscillator is configured as a crystal (hs, xt, or lp), the cpu will be held in the q1 state until 1024 clock cycles have transpired on the primary clock. this is necessary because the crystal oscillator had been powered down (see figure 3-9). during the oscillator start-up time, the system clock does not come from the secondary oscillator, intosc. instruction execution and/or peripheral operation is suspended and intosc is disabled. if the primary system clock is either rc, ec or intosc, the cpu will begin operating on the first q1 cycle following the wake-up event. this means that there is no oscillator start-up time required because the primary clock is already stable; however, there is a delay between the wake-up event and the following q2. an internal delay timer of 5-10 s will suspend operation after the reset to allow the cpu to become ready for code execution. the cpu and peripheral clock will be held in the first q1 following the exit from low power. the clocks will be released on the next falling edge of the input system clock. the cpu will advance the system clock into the q2 state following two rising edges of the incoming clock on osc1. the extra clock transition is required following a reset to allow the system clock to synchronize to the asynchronous nature of the reset source (see figure 3-10). the sequence of events is as follows: 1. a device reset is asserted from one of many sources (wdt, bod, mclr , etc.). 2. the device resets and the cpu start-up timer is enabled if in sleep mode. the device is held in reset until the cpu start-up time-out is complete. 3. if the primary system clock is configured as an external oscillator (hs, xt, lp), then the ost will be active waiting for 1024 clocks of the primary system clock. while waiting for the ost, the device will be held in reset. the ost and cpu start-up timers run in parallel. 4. after both the cpu start-up and ost timers have timed out, the device will wait for one additional clock cycle and instruction execution will begin. figure 3-9: primary oscillator after reset (hs, xt, lp) note: if two-speed clock start-up or fail-safe clock monitor is enabled, the intosc will act as the system clock until the oscillator start-up timer has timed out. q2 q4 q1 q3 q4 q1 q2 osc1 peripheral sleep program pc 0000h intosc t ost q3 t osc t int q4 osc2 osts system clock 0001h q1 q3 q4 q1 q2 clock counter 0004h 0005h 0003h q1 q2 q3 q4 reset t epu note 1: t int = 32 s maximum 2: t osc = 50 ns minimum 3: t epu = 5-10 s cpu start-up
PIC12F683 ds41211a-page 30 advance information ? 2003 microchip technology inc. figure 3-10: primary oscillator after reset (ec, rc, intosc) q4 q1 q3 q4 q1 q2 osc1 program pc 0000h intosc q3 t int q4 osc2 osts system clock 0001h q1 q2 q3 q4 q1 q2 counter 0003h 0004h 0002h q1 q2 q3 q4 mclr t cpu (2) note 1: t int = 32 s maximum 2: t cpu = 5-10 s cpu start-up
? 2003 microchip technology inc. advance information ds41211a-page 31 PIC12F683 table 3-4: clock switching modes current system clock scs bit modified to: delay osts bit hts/lts bit new system clock comments lp, xt, hs, ec, rc 1 (intosc) next falling edge of intosc 0 1 (1) intrc or intosc or intosc postscaler the intosc oscillator frequency is dependent upon the ircf bits. intosc 0 fosc<2:0> = ec or fosc<2:0> = rc next falling edge of ec or rc 1 n/a ec or rc intosc 0 fosc<2:0> = lp, xt, hs 1024 clocks (ost) 1 n/a lp, xt, hs during the 1024 clocks, program execution is clocked from the secondary oscillator until the primary oscillator becomes stable. lp, xt, hs 0 (due to reset) lp, xt, hs 1024 clocks (ost) 1 n/a lp, xt, hs when a reset occurs, there is no clock transition sequence. instruction execution and/or peripheral operation is suspended unless two-speed start-up or fail-safe clock monitor is enabled, after which the intosc will act as the sys- tem clock until the ost timer has expired. note 1: if the ircf<2:0> bits select 31 khz, the lts bit will be set after the intrc is stable. if the ircf<2:0> bits select 125 khz to 8 mhz, the hts bit will be set after the intosc is stable.
PIC12F683 ds41211a-page 32 advance information ? 2003 microchip technology inc. 3.6.8.3 exiting sleep the scs bit (osccon<0>) is unaffected by a sleep command. the clock source used after an exit from sleep is determined by the scs bit. 3.6.8.4 sequence of events if scs = 0 : 1. the device is held in sleep until the cpu start-up time-out is complete. 2. if the primary system clock is configured as an external oscillator (hs, xt, lp), then the ost will be active waiting for 1024 clocks of the primary system clock. while waiting for the ost, the device will be held in sleep unless two-speed start-up or fail-safe clock monitor is enabled. the ost and cpu start-up timers run in parallel. 3. after both the cpu start-up and ost timers have timed out, the device will exit sleep and begin instruction execution with the primary clock defined by the f osc bits. if scs = 1 : 1. the device is held in sleep until the cpu start-up time-out is complete. 2. after the cpu start-up timer has timed out, the device will exit sleep and begin instruction execution with secondary oscillator, intosc. refer to section 12.6.3 ?two-speed clock start-up mode? and section 12.6.4 ?fail-safe clock moni- tor? for details . table 3-5: summary of registers associated with oscillators note: if a user changes scs just before entering sleep mode, the system clock used when exiting sleep mode could be different than the system clock used when entering sleep mode. for example, if scs = 1 , the system clock is xt, lp or hs, and the following instructions are executed: bcf osccon,scs sleep then a clock change event is executed. the core will continue to run off intosc and execute the sleep command. when sleep is exited, the part will resume operation with the primary oscillator after the ost has expired. address name bit 7 bit 6 bit 5 bit 4 bit 3 bit 2 bit 1 bit 0 value on: por, bod value on all other resets 0ch pir1 eeif adif ccp1if ? cmif osfif tmr2if tmr1if 000- 0000 000- 0000 8ch pie1 eeie adie ccp1ie ? cmie osfie tmr2ie tmr1ie 000- 0000 000- 0000 8fh osccon ? ircf2 ircf1 ircf0 osts hts lts scs -110 x000 -110 x000 90h osctune ? ? ? tun4 tun3 tun2 tun1 tun0 ---0 0000 ---u uuuu 2007h (1) config bits cpd cp mclre pwrte wdte fosc2 f0sc1 f0sc0 legend: x = unknown, u = unchanged, ? = unimplemented locations read as ? 0 ?. shaded cells are not used by oscillators. note 1: see register 12-1 for operation of these bits.
? 2003 microchip technology inc. advance information ds41211a-page 33 PIC12F683 4.0 gpio ports there are as many as six general purpose i/o pins available. depending on which peripherals are enabled, some or all of the pins may not be available as general purpose i/o. in general, when a peripheral is enabled, the associated pin may not be used as a general purpose i/o pin. 4.1 gpio and the trisio registers gpio is an 6-bit wide, bidirectional port. the corresponding data direction register is trisio. setting a trisio bit (= 1 ) will make the corresponding gpio pin an input (i.e., put the corresponding output driver in a high-impedance mode). clearing a trisio bit (= 0 ) will make the corresponding gpio pin an output (i.e., put the contents of the output latch on the selected pin). the exception is gp3, which is input only and its trisio bit will always read as ? 1 ?. example 4-1 shows how to initialize gpio. reading the gpio register reads the status of the pins, whereas writing to it will write to the port latch. all write operations are read-modify-write operations. there- fore, a write to a port implies that the port pins are read, this value is modified and then written to the port data latch. gp3 reads ? 0 ? when mclre = 1 . the trisio register controls the direction of the gpio pins, even when they are being used as analog inputs. the user must ensure the bits in the trisio register are maintained set when using them as analog inputs. i/o pins configured as analog input always read ? 0 ?. example 4-1: initializing gpio 4.2 additional pin functions every gpio pin on the PIC12F683 has an interrupt-on- change option and a weak pull-up option. gp0 has a ultra low-power wake-up option. the next three sections describe these functions. 4.2.1 weak pull-ups each of the gpio pins, except gp3, has an individually configurable weak internal pull-up. control bits wpux enable or disable each pull-up. refer to register 4-3. each weak pull-up is automatically turned off when the port pin is configured as an output. the pull-ups are disabled on a power-on reset by the gpp u bit (option<7>). a weak pull-up is automatically enabled for gp3 when configured as mclr and disabled when gp3 is an i/o. there is no software control of the mclr pull-up. register 4-1: gpio ? general purpose i/o register (address: 05h) note: additional information on i/o ports may be found in the picmicro ? mid-range refer- ence manual (ds33023). note: the ansel (9fh) and cmcon0 (19h) registers must be initialized to configure an analog channel as a digital input. pins configured as analog inputs will read ? 0 ?. bcf status,rp0 ;bank 0 clrf gpio ;init gpio movlw 07h ;set gp<2:0> to movwf cmcon0 ;digital i/o bsf status,rp0 ;bank 1 clrf ansel ;digital i/o movlw 0ch ;set gp<3:2> as inputs movwf trisio ;and set gp<5:4,1:0> ;as outputs bcf status,rp0 ;bank 0 u-0 u-0 r/w-x r/w-x r/w-x r/w-x r/w-x r/w-x ? ? gp5 gp4 gp3 gp2 gp1 gp0 bit 7 bit 0 bit 7-6: unimplemented : read as ? 0 ? bit 5-0: gpio<5:0> : gpio i/o pin 1 = port pin is >v ih 0 = port pin is PIC12F683 ds41211a-page 34 advance information ? 2003 microchip technology inc. register 4-2: trisio ? gpio tristate register (address: 85h) register 4-3: wpu ? weak pull-up register (address: 95h) u-0 u-0 r/w-1 r/w-1 r-1 r/w-1 r/w-1 r/w-1 ? ? trisio5 trisio4 trisio3 trisio2 trisio1 trisio0 bit 7 bit 0 bit 7-6: unimplemented : read as ? 0 ? bit 5-0: trisio<5:0> : gpio tri-state control bit 1 = gpio pin configured as an input (tri-stated) 0 = gpio pin configured as an output note 1: trisio<3> always reads ? 1 ?. 2: trisio<5:4> reads ? 1 ? in xt, lp and hs modes. legend: r = readable bit w = writable bit u = unimplemented bit, read as ?0? - n = value at por ?1? = bit is set ?0? = bit is cleared x = bit is unknown u-0 u-0 r/w-1 r/w-1 u-0 r/w-1 r/w-1 r/w-1 ? ? wpu5 wpu4 ? wpu2 wpu1 wpu0 bit 7 bit 0 bit 7-6 unimplemented: read as ? 0 ? bit 5-4 wpu<5:4>: weak pull-up register bit 1 = pull-up enabled 0 = pull-up disabled bit 3 unimplemented: read as ? 0 ? bit 2-0 wpu<2:0>: weak pull-up register bit 1 = pull-up enabled 0 = pull-up disabled note 1: global gpp u must be enabled for individual pull-ups to be enabled. 2: the weak pull-up device is automatically disabled if the pin is in output mode (trisio = 0). 3: the gp3 pull-up is enabled when configured as mclr and disabled as an i/o in the configuration word. 4: wpu<5:4> reads ? 1 ? in xt, lp and hs modes. legend: r = readable bit w = writable bit u = unimplemented bit, read as ?0? - n = value at por ?1? = bit is set ?0? = bit is cleared x = bit is unknown
? 2003 microchip technology inc. advance information ds41211a-page 35 PIC12F683 4.2.2 interrupt-on-change each of the gpio pins is individually configurable as an interrupt-on-change pin. control bits iocx enable or disable the interrupt function for each pin. refer to register 4-4. the interrupt-on-change is disabled on a power-on reset. for enabled interrupt-on-change pins, the values are compared with the old value latched on the last read of gpio. the ?mismatch? outputs of the last read are or'd together to set, the gpio change interrupt flag bit (gpif) in the intcon register. this interrupt can wake the device from sleep. the user, in the interrupt service routine, can clear the interrupt in the following manner: a) any read or write of gpio. this will end the mis- match condition. b) clear the flag bit gpif. a mismatch condition will continue to set flag bit gpif. reading gpio will end the mismatch condition and allow flag bit gpif to be cleared. the latch holding the last read value is not affected by a mclr nor bod reset. after these resets, the gpif flag will continue to be set if a mismatch is present. register 4-4: ioc ? interrupt-on-change gpio regist er (address: 96h) note: if a change on the i/o pin should occur when the read operation is being executed (start of the q2 cycle), then the gpif interrupt flag may not get set. u-0 u-0 r/w-0 r/w-0 r/w-0 r/w-0 r/w-0 r/w-0 ? ? ioc5 ioc4 ioc3 ioc2 ioc1 ioc0 bit 7 bit 0 bit 7-6 unimplemented: read as ? 0 ? bit 5-0 ioc<5:0>: interrupt-on-change gpio control bit 1 = interrupt-on-change enabled 0 = interrupt-on-change disabled note 1: global interrupt enable (gie) must be enabled for individual interrupts to be recognized. 2: ioc<5:4> reads ? 1 ? in xt, lp and hs modes. legend: r = readable bit w = writable bit u = unimplemented bit, read as ?0? - n = value at por ?1? = bit is set ?0? = bit is cleared x = bit is unknown
PIC12F683 ds41211a-page 36 advance information ? 2003 microchip technology inc. 4.2.3 ultra low-power wake-up the ultra low-power wake-up on gp0 allows a slow falling voltage to generate an interrupt-on-change on gp0 without excess current consumption. the mode is selected by setting the ulpwue bit (pcon<5>). this enables a small current sink which can be used to discharge a capacitor on gp0. to use this feature, the gp 0 pin is configured to output ? 1 ? to charge the capacitor, interrupt-on-change for gp0 is enabled, and gp0 is configured as an input. the ulpwue bit is set to begin the discharge and a sleep instruction is performed. when the voltage on gp0 drops below v il , an interrupt will be generated which will cause the device to wake-up. depending on the state of the gie bit (intcon<7>), the device will either jump to the interrupt vector (0004h) or execute the next instruc- tion when the interrupt event occurs. see section 4.2.2 ?interrupt-on-change? and section 12.4.3 ?gpio interrupt? for more information. this feature provides a low-power technique for period- ically waking up the device from sleep. the time-out is dependent on the discharge time of the rc circuit on gp0. see example 4-2 for initializing the ultra low- power wake-up module. the series resistor provides over-current protection for the capacitor and can allow for software calibration of the time-out. see figure 4-1. a timer can be used to measure the charge time and discharge time of the capacitor. the charge time can then be adjusted to provide the desired interrupt delay. this technique will compensate for the affects of temperature, voltage and component accuracy. the ultra low-power wake-up peripheral can also be configured as a simple programmable low-voltage detect or temperature sensor. example 4-2: ultra low-power wake-up initialization figure 4-1: ultra low-power wake-up circuit bcf status,rp0 ;bank 0 bsf gpio,0 ;set gp0 data latch movlw h?7? ;turn off movwf cmcon0 ; comparator bsf status,rp0 ;bank 1 bcf ansel,0 ;gp0 to digital i/o bcf trisio,0 ;output high to call capdelay ; charge capacitor bsf pcon,ulpwue ;enable ulp wake-up bsf ioc,0 ;select gp0 ioc bsf trisio,0 ;gp0 to input movlw b?10001000? ;enable interrupt movwf intcon ; and clear flag sleep ;wait for ioc PIC12F683 gp0 r1 c1
? 2003 microchip technology inc. advance information ds41211a-page 37 PIC12F683 4.2.4 pin descriptions and diagrams each gpio pin is multiplexed with other functions. the pins and their combined functions are briefly described here. for specific information about individual functions such as the comparator or the a/d, refer to the appropriate section in this data sheet. 4.2.4.1 gp0/an0/cin+/icspdat figure 4-2 shows the diagram for this pin. the gp0 pin is configurable to function as one of the following:  a general purpose i/o  an analog input for the a/d  an analog input to the comparator  an analog input to the ultra low-power wake-up  in-circuit serial programming data figure 4-2: block diagram of gp0 4.2.4.2 gp1/an1/cin-/v ref /icspclk figure 4-2 shows the diagram for this pin. the gp1 pin is configurable to function as one of the following:  a general purpose i/o  an analog input for the a/d  a analog input to the comparator  a voltage reference input for the a/d  in-circuit serial programming clock figure 4-3: block diagram of gp1 i/o pin v dd v ss d q ck q d q ck q d q ck q d q ck q v dd d en q d en q weak data bus wr wpu rd wpu rd gpio rd gpio wr gpio wr trisio rd trisio wr ioc rd ioc interrupt-on- to comparator to a/d converter analog input mode gpp u analog input mode change to ultra low-power wake-up i/o pin v dd v ss d q ck q d q ck q d q ck q d q ck q v dd d en q d en q weak data bus wr wpu rd wpu rd gpio rd gpio wr gpio wr trisio rd trisio wr ioc rd ioc interrupt-on- to comparator to a/d converter analog input mode gpp u analog input mode change
PIC12F683 ds41211a-page 38 advance information ? 2003 microchip technology inc. 4.2.4.3 gp2/an2/t0cki/int/cout figure 4-4 shows the diagram for this pin. the gp2 pin is configurable to function as one of the following:  a general purpose i/o  an analog input for the a/d  the clock input for tmr0  an external edge triggered interrupt  a digital output from the comparator figure 4-4: block diagram of gp2 4.2.4.4 gp3/mclr /v pp figure 4-5 shows the diagram for this pin. the gp3 pin is configurable to function as one of the following:  a general purpose input  as master clear reset with weak pull-up figure 4-5: block diagram of gp3 i/o pin v dd v ss d q ck q d q ck q d q ck q d q ck q v dd d en q d en q weak analog input mode data bus wr wpu rd wpu rd gpio wr gpio wr trisio rd trisio wr ioc rd ioc to a/d converter 0 1 cout cout enable to int to t m r 0 analog input mode gpp u rd gpio analog input mode interrupt-on- change input v ss d q ck q d en q data bus rd gpio rd gpio wr ioc rd ioc reset mclre rd trisio v ss d en q mclre v dd weak mclre interrupt-on- change pin
? 2003 microchip technology inc. advance information ds41211a-page 39 PIC12F683 4.2.4.5 gp4/an3/t1g /osc2/clkout figure 4-6 shows the diagram for this pin. the gp4 pin is configurable to function as one of the following:  a general purpose i/o  an analog input for the a/d  a tmr1 gate input  a crystal/resonator connection  a clock output figure 4-6: block diagram of gp4 4.2.4.6 gp5/t1cki/osc1/clkin figure 4-7 shows the diagram for this pin. the gp5 pin is configurable to function as one of the following:  a general purpose i/o a tmr1 clock input  a crystal/resonator connection  a clock input figure 4-7: block diagram of gp5 i/o pin v dd v ss d q ck q d q ck q d q ck q d q ck q v dd d en q d en q weak analog input mode data bus wr wpu rd wpu rd gpio wr gpio wr trisio rd trisio wr ioc rd ioc f osc /4 to a/d converter oscillator circuit osc1 clkout 0 1 clkout enable enable analog input mode gpp u rd gpio to t 1 g intosc/ rc/ec (2) clk (1) modes clkout enable note 1: clk modes are xt, hs, lp, lptmr1 and clkout enable. 2: with clkout option. interrupt-on- change i/o pin v dd v ss d q ck q d q ck q d q ck q d q ck q v dd d en q d en q weak data bus wr wpu rd wpu rd gpio wr gpio wr trisio rd trisio wr ioc rd ioc to tmr1 or clkgen intosc mode rd gpio intosc mode gpp u osc2 (1) note 1: timer1 lp oscillator enabled. 2: when using timer1 with lp oscillator, the schmitt trigger is bypassed. tmr1lpen (1) interrupt-on- change oscillator circuit
PIC12F683 ds41211a-page 40 advance information ? 2003 microchip technology inc. table 4-1: summary of registers associated with gpio addr name bit 7 bit 6 bit 5 bit 4 bit 3 bit 2 bit 1 bit 0 value on: por, bod value on all other resets 05h gpio ? ? gp5 gp4 gp3 gp2 gp1 gp0 --xx xxxx --uu uuuu 0bh/8bh intcon gie peie t0ie inte gpie t0if intf gpif 0000 0000 0000 0000 19h cmcon0 ? cout ? cinv cis cm2 cm1 cm0 -0-0 0000 -0-0 0000 81h option_reg gpp u intedg t0cs t0se psa ps2 ps1 ps0 1111 1111 1111 1111 85h trisio ? ? trisio5 trisio4 trisio3 trisio2 trisio1 trisio0 --11 1111 --11 1111 95h wpu ? ? wpu5 wpu4 ? wpu2 wpu1 wpu0 --11 -111 --11 -111 96h ioc ? ? ioc5 ioc4 ioc3 ioc2 ioc1 ioc0 --00 0000 --00 0000 9fh ansel ? adcs2 adcs1 adcs0 ans3 ans2 ans1 ans0 -000 1111 -000 1111 legend: x = unknown, u = unchanged, ? = unimplemented locations read as ? 0 ?. shaded cells are not used by gpio.
? 2003 microchip technology inc. advance information ds41211a-page 41 PIC12F683 5.0 timer0 module the timer0 module timer/counter has the following features:  8-bit timer/counter  readable and writable  8-bit software programmable prescaler  internal or external clock select  interrupt on overflow from ffh to 00h  edge select for external clock figure 5-1 is a block diagram of the timer0 module and the prescaler shared with the wdt. 5.1 timer0 operation timer mode is selected by clearing the t0cs bit (option_reg<5>). in timer mode, the timer0 module will increment every instruction cycle (without prescaler). if tmr0 is written, the increment is inhibited for the following two instruction cycles. the user can work around this by writing an adjusted value to the tmr0 register. counter mode is selected by setting the t0cs bit (option_reg<5>). in this mode, the timer0 module will increment either on every rising or falling edge of pin gp2/t0cki. the incrementing edge is determined by the source edge (t0se) control bit (option_reg<4>). clearing the t0se bit selects the rising edge. 5.2 timer0 interrupt a timer0 interrupt is generated when the tmr0 register timer/counter overflows from ffh to 00h. this overflow sets the t0if bit (intcon<2>). the interrupt can be masked by clearing the t0ie bit (intcon<5>). the t0if bit must be cleared in software by the timer0 module interrupt service routine before re-enabling this interrupt. the timer0 interrupt cannot wake the processor from sleep since the timer is shut off during sleep. figure 5-1: block diagram of the timer0/wdt prescaler note: additional information on the timer0 module is available in the picmicro ? mid- range reference manual , (ds33023). note: counter mode has specific external clock requirements. additional information on these requirements is available in the picmicro ? mid-range reference manual , (ds33023). t0cki t0se pin clkout tmr0 watchdog timer wdt time-out ps0-ps2 wdte data bus set flag bit t0if on overflow t0cs note 1: t0se, t0cs, psa, ps0-ps2 are bits in the option register, wdtps<3:0> are bits in the wdtcon register. 0 1 0 1 0 1 sync 2 cycles 8 8 8-bit prescaler 0 1 (= f osc /4) psa psa psa 16-bit prescaler 16 wdtps<3:0> 31 khz intrc swdten
PIC12F683 ds41211a-page 42 advance information ? 2003 microchip technology inc. 5.3 using timer0 with an external clock when no prescaler is used, the external clock input is the same as the prescaler output. the synchronization of t0cki, with the internal phase clocks, is accom- plished by sampling the prescaler output on the q2 and q4 cycles of the internal phase clocks. therefore, it is necessary for t0cki to be high for at least 2t osc (and a small rc delay of 20 ns) and low for at least 2t osc (and a small rc delay of 20 ns). refer to the electrical specification of the desired device. 5.4 prescaler an 8-bit counter is available as a prescaler for the timer0 module, or as a postscaler for the watchdog timer. for simplicity, this counter will be referred to as ?prescaler? throughout this data sheet. the prescaler assignment is controlled in software by the control bit psa (option_reg<3>). clearing the psa bit will assign the prescaler to timer0. prescale values are selectable via the ps2:ps0 bits (option_reg<2:0>). the prescaler is not readable or writable. when assigned to the timer0 module, all instructions writing to the tmr0 register (e.g., clrf 1, movwf 1, bsf 1, x....etc. ) will clear the prescaler. when assigned to wdt, a clrwdt instruction will clear the prescaler along with the watchdog timer. 5.4.1 switching prescaler assignment the prescaler assignment is fully under software control (i.e., it can be changed ?on the fly? during program execution). to avoid an unintended device reset, the following instruction sequence (example 5- 1 and example 5-2) must be executed when changing the prescaler assignment from timer0 to wdt. example 5-1: changing prescaler (timer0  wdt) to change prescaler from the wdt to the tmr0 module, use the sequence shown in example 5-2. this precaution must be taken even if the wdt is disabled. example 5-2: changing prescaler (wdt  timer0) table 5-1: registers associated with timer0 note: the ansel (9fh) and cmcon0 (19h) registers must be initialized to configure an analog channel as a digital input. pins configured as analog inputs will read ? 0 ?. bcf status,rp0 ;bank 0 clrwdt ;clear wdt clrf tmr0 ;clear tmr0 and ; prescaler bsf status,rp0 ;bank 1 movlw b?00101111? ;required if desired movwf option_reg ; ps2:ps0 is clrwdt ; 000 or 001 ; movlw b?00101xxx? ;set postscaler to movwf option_reg ; desired wdt rate bcf status,rp0 ;bank 0 clrwdt ;clear wdt and ; prescaler bsf status,rp0 ;bank 1 movlw b?xxxx0xxx? ;select tmr0, ; prescale, and ; clock source movwf option_reg ; bcf status,rp0 ;bank 0 addr name bit 7 bit 6 bit 5 bit 4 bit 3 bit 2 bit 1 bit 0 value on por, bod value on all other resets 01h tmr0 timer0 module register xxxx xxxx uuuu uuuu 0bh/ 8bh intcon gie peie t0ie inte gpie t0if intf gpif 0000 0000 0000 0000 81h option_reg gpp u intedg t0cs t0se psa ps2 ps1 ps0 1111 1111 1111 1111 85h trisio ? ? trisio5 trisio4 trisio3 trisio2 trisio1 trisio0 --11 1111 --11 1111 legend: ? = unimplemented locations, read as ? 0 ?, u = unchanged, x = unknown. shaded cells are not used by the timer0 module.
? 2003 microchip technology inc. advance information ds41211a-page 43 PIC12F683 6.0 timer1 module with gate control the PIC12F683 has a 16-bit timer. figure 6-1 shows the basic block diagram of the timer1 module. timer1 has the following features:  16-bit timer/counter (tmr1h:tmr1l)  readable and writable  internal or external clock selection  synchronous or asynchronous operation  interrupt on overflow from ffffh to 0000h  wake-up upon overflow (asynchronous mode)  optional external enable input - selectable gate source; t1g or cout (t1gss) - selectable gate polarity (t1ginv)  optional lp oscillator the timer1 control register (t1con), shown in register 6-1, is used to enable/disable timer1 and select the various features of the timer1 module. figure 6-1: timer1 on the pi c12f683 block diagram note: additional information on timer modules is available in the picmicro ? mid-range reference manual , (ds33023). tmr1h tmr1l oscillator t1sync tmr1cs t1ckps<1:0> sleep input f osc /4 internal clock prescaler 1, 2, 4, 8 synchronize det 1 0 0 1 synchronized clock input 2 osc1/t1cki osc2/t1g set flag bit tmr1if on overflow tmr1 (1) tmr1on tmr1ge tmr1on tmr1ge intosc t1oscen without clkout * 1 0 cout t1gss t1ginv to comparator module tmr1 clock * st buffer is low-power type when using lp oscillator, or high-speed type when using t1cki. note 1: timer 1 increments on the rising edge.
PIC12F683 ds41211a-page 44 advance information ? 2003 microchip technology inc. 6.1 timer1 modes of operation timer1 can operate in one of three modes:  16-bit timer with prescaler  16-bit synchronous counter  16-bit asynchronous counter in timer mode, timer1 is incremented on every instruction cycle. in counter mode, timer1 is incremented on the rising edge of the external clock input t1cki. in addition, the counter mode clock can be synchronized to the microcontroller system clock or run asynchronously. in counter and timer modules, the counter/timer clock can be gated by the timer 1 gate, which can be selected as either the t1g pin or the comparator output. if an external clock oscillator is needed (and the microcontroller is using the intosc w/o clkout), timer1 can use the lp oscillator as a clock source. 6.2 timer1 interrupt the timer1 register pair (tmr1h:tmr1l) increments to ffffh and rolls over to 0000h. when timer1 rolls over, the timer1 interrupt flag bit (pir1<0>) is set. to enable the interrupt on rollover, you must set these bits:  timer1 interrupt enable bit (pie1<0>)  peie bit (intcon<6>)  gie bit (intcon<7>). the interrupt is cleared by clearing the tmr1if in the interrupt service routine. 6.3 timer1 prescaler timer1 has four prescaler options allowing 1, 2, 4, or 8 divisions of the clock input. the t1ckps bits (t1con<5:4>) control the prescale counter. the prescale counter is not directly readable or writable; however, the prescaler counter is cleared upon a write to tmr1h or tmr1l. 6.4 timer1 gate timer1 gate source is software configurable to be t1g pin or the output of the comparator. this allows the device to directly time external events using t1g or analog events using the comparator. see cmcon1 (register 9-2) for selecting the timer1 gate source. this feature can simplify the software for a delta-sigma a/d converter and many other applications. for more information on delta-sigma a/d converters, see the microchip web site (www.microchip.com). timer1 gate can be inverted by using the t1ginv bit (t1con<7>), whether it originates from the t1g pin or the comparator output. this configures timer1 to measure either the active high or active low time between events. figure 6-2: timer1 incrementing edge note: in counter mode, a falling edge must be registered by the counter prior to the first incrementing rising edge. note: the tmr1h:ttmr1l register pair and the tmr1if bit should be cleared before enabling interrupts. note: tmr1ge bit (t1con<6>) must be set to use either t1g or cout as the timer1 gate source. see register 9-2 for more information on selecting the timer1 gate source. t1cki = 1 when tmr1 enabled t1cki = 0 when tmr1 enabled note 1: arrows indicate counter increments. 2: in counter mode, a falling edge must be registered by the counter prior to the first incrementing rising edge of the clock.
? 2003 microchip technology inc. advance information ds41211a-page 45 PIC12F683 register 6-1: t1con ? timer1 control regi ster (address: 10h) r/w-0 r/w-0 r/w-0 r/w-0 r/w-0 r/w-0 r/w-0 r/w-0 t1ginv tmr1ge t1ckps1 t1ckps0 t1oscen t1sync tmr1cs tmr1on bit 7 bit 0 bit 7 t1ginv: timer1 gate invert bit (1) 1 = timer1 gate is inverted 0 = timer1 gate is not inverted bit 6 tmr1ge: timer1 gate enable bit (2) if tmr1on = 0: this bit is ignored if tmr1on = 1: 1 = timer1 is on if timer1 gate is not active 0 = timer1 is on bit 5-4 t1ckps1:t1ckps0: timer1 input clock prescale select bits 11 = 1:8 prescale value 10 = 1:4 prescale value 01 = 1:2 prescale value 00 = 1:1 prescale value bit 3 t1oscen: lp oscillator enable control bit if intosc without clkout oscillator is active: 1 = lp oscillator is enabled for timer1 clock 0 = lp oscillator is off else: this bit is ignored bit 2 t1sync : timer1 external clock input synchronization control bit tmr1cs = 1: 1 = do not synchronize external clock input 0 = synchronize external clock input tmr1cs = 0: this bit is ignored. timer1 uses the internal clock. bit 1 tmr1cs: timer1 clock source select bit 1 = external clock from t1cki pin (on the rising edge) 0 = internal clock (f osc /4) bit 0 tmr1on: timer1 on bit 1 = enables timer1 0 = stops timer1 note 1: t1ginv bit inverts the timer1 gate logic, regardless of source. 2: tmr1ge bit must be set to use either t1g pin or cout, as selected by t1gss bit (cmcon1<1>), as a timer1 gate source. legend: r = readable bit w = writable bit u = unimplemented bit, read as ?0? - n = value at por ?1? = bit is set ?0? = bit is cleared x = bit is unknown
PIC12F683 ds41211a-page 46 advance information ? 2003 microchip technology inc. 6.5 timer1 operation in asynchronous counter mode if control bit t1sync (t1con<2>) is set, the external clock input is not synchronized. the timer continues to increment asynchronous to the internal phase clocks. the timer will continue to run during sleep and can generate an interrupt on overflow, which will wake-up the processor. however, special precautions in software are needed to read/write the timer ( section 6.5.1 ?reading and writing timer1 in asynchronous counter mode? ). 6.5.1 reading and writing timer1 in asynchronous counter mode reading tmr1h or tmr1l while the timer is running from an external asynchronous clock will ensure a valid read (taken care of in hardware). however, the user should keep in mind that reading the 16-bit timer in two 8-bit values itself, poses certain problems, since the timer may overflow between the reads. for writes, it is recommended that the user simply stop the timer and write the desired values. a write contention may occur by writing to the timer registers, while the register is incrementing. this may produce an unpredictable value in the timer register. reading the 16-bit value requires some care. examples in the picmicro ? mid-range mcu family reference manual (ds33023) show how to read and write timer1 when it is running in asynchronous mode. 6.6 timer1 oscillator a crystal oscillator circuit is built-in between pins osc1 (input) and osc2 (amplifier output). it is enabled by setting control bit t1oscen (t1con<3>). the oscilla- tor is a low-power oscillator rated up to 32 khz. it will continue to run during sleep. it is primarily intended for a 32 khz crystal. table 3-1 shows the capacitor selection for the timer1 oscillator. the timer1 oscillator is shared with the system lp oscillator. thus, timer1 can use this mode only when the primary system clock is derived from the internal oscillator. as with the system lp oscillator, the user must provide a software time delay to ensure proper oscillator start-up. trisio5 and trisio4 bits are set when the timer1 oscillator is enabled. gp5 and gp4 read as ? 0 ? and trisio5 and trisio4 bits read as ? 1 ?. 6.7 timer1 operation during sleep timer1 can only operate during sleep when setup in asynchronous counter mode. in this mode, an external crystal or clock source can be used to increment the counter. to setup the timer to wake the device:  timer1 must be on (t1con<0>)  tmr1ie bit (pie1<0>) must be set  peie bit (intcon<6>) must be set the device will wake-up on an overflow. if the gie bit (intcon<7>) is set, the device will wake-up and jump to the interrupt service routine (0004h) on an overflow. if the gie bit is clear, execution will continue with the next instruction. table 6-1: registers associated with timer1 note: the ansel (9fh) and cmcon0 (19h) registers must be initialized to configure an analog channel as a digital input. pins configured as analog inputs will read ? 0 ?. note: the oscillator requires a start-up and stabilization time before use. thus, t1oscen should be set and a suitable delay observed prior to enabling timer1. addr name bit 7 bit 6 bit 5 bit 4 bit 3 bit 2 bit 1 bit 0 value on por, bod value on all other resets 0bh/ 8bh intcon gie peie t0ie inte gpie t0if intf gpif 0000 0000 0000 0000 0ch pir1 eeif adif ccp1if ? cmif osfif tmr2if tmr1if 000- 0000 000- 0000 0eh tmr1l holding register for the least significant byte of the 16-bit tmr1 register xxxx xxxx uuuu uuuu 0fh tmr1h holding register for the most significant byte of the 16-bit tmr1 register xxxx xxxx uuuu uuuu 10h t1con t1ginv tmr1ge t1ckps1 t1ckps0 t1oscen t1sync tmr1cs tmr1on 0000 0000 uuuu uuuu 1ah cmcon1 ? ? ? ? ? ?t1gss cmsync ---- --10 ---- --10 8ch pie1 eeie adie ccp1ie ? cmie osfie tmr2ie tmr1ie 000- 0000 000- 0000 legend: x = unknown, u = unchanged, ? = unimplemented, read as ? 0 ?. shaded cells are not used by the timer1 module.
? 2003 microchip technology inc. advance information ds41211a-page 47 PIC12F683 7.0 timer2 module the timer2 module timer has the following features:  8-bit timer (tmr2 register)  8-bit period register (pr2)  readable and writable (both registers)  software programmable prescaler (1:1, 1:4, 1:16)  software programmable postscaler (1:1 to 1:16)  interrupt on tmr2 match with pr2 timer2 has a control register shown in register 7-1. tmr2 can be shut off by clearing control bit tmr2on (t2con<2>) to minimize power consumption. figure 7-1 is a simplified block diagram of the timer2 module. the prescaler and postscaler selection of timer2 are controlled by this register. 7.1 timer2 operation timer2 can be used as the pwm time base for the pwm mode of the ccp module. the tmr2 register is readable and writable, and is cleared on any device reset. the input clock (f osc /4) has a prescale option of 1:1, 1:4 or 1:16, selected by control bits t2ckps1:t2ckps0 (t2con<1:0>). the match out- put of tmr2 goes through a 4-bit postscaler (which gives a 1:1 to 1:16 scaling inclusive) to generate a tmr2 interrupt (latched in flag bit tmr2if, (pir1<1>)). the prescaler and postscaler counters are cleared when any of the following occurs:  a write to the tmr2 register  a write to the t2con register  any device reset (power-on reset, mclr reset, watchdog timer reset or brown-out reset) tmr2 is not cleared when t2con is written. register 7-1: t2con ? timer2 control regi ster (address: 12h) u-0 r/w-0 r/w-0 r/w-0 r/w-0 r/w-0 r/w-0 r/w-0 ? toutps3 toutps2 toutps1 toutps0 tmr2on t2ckps1 t2ckps0 bit 7 bit 0 bit 7 unimplemented: read as ? 0 ? bit 6-3 toutps3:toutps0: timer2 output postscale select bits 0000 =1:1 postscale 0001 =1:2 postscale    1111 =1:16 postscale bit 2 tmr2on: timer2 on bit 1 =timer2 is on 0 =timer2 is off bit 1-0 t2ckps1:t2ckps0: timer2 clock prescale select bits 00 =prescaler is 1 01 =prescaler is 4 1x =prescaler is 16 legend: r = readable bit w = writable bit u = unimplemented bit, read as ?0? - n = value at por ?1? = bit is set ?0? = bit is cleared x = bit is unknown
PIC12F683 ds41211a-page 48 advance information ? 2003 microchip technology inc. 7.2 timer2 interrupt the timer2 module has an 8-bit period register, pr2. timer2 increments from 00h until it matches pr2 and then resets to 00h on the next increment cycle. pr2 is a readable and writable register. the pr2 register is initialized to ffh upon reset. figure 7-1: timer2 block diagram table 7-1: registers associated with timer2 addr name bit 7 bit 6 bit 5 bit 4 bit 3 bit 2 bit 1 bit 0 value on por, bod value on all other resets 0bh/ 8bh intcon gie peie t0ie inte gpie t0if intf gpif 0000 0000 0000 0000 0ch pir1 eeif adif ccp1if ? cmif osfif tmr2if tmr1if 000- 0000 000- 0000 11h tmr2 holding register for the 8-bit tmr2 register 0000 0000 0000 0000 12h t2con ? toutps3 toutps2 toutps1 toutps0 tmr2on t2ckps1 t2ckps0 -000 0000 -000 0000 8ch pie1 eeie adie ccp1ie ? cmie osfie tmr2ie tmr1ie 000- 0000 000- 0000 92h pr2 timer2 module period register 1111 1111 1111 1111 legend: x = unknown, u = unchanged, ? = unimplemented, read as ? 0 ?. shaded cells are not used by the timer2 module. comparator tmr2 sets flag tmr2 output reset postscaler prescaler pr2 2 f osc /4 1:1 to 1:16 1:1, 1:4, 1:16 eq 4 bit tmr2if toutps3:toutps0 t2ckps1:t2ckps0
? 2003 microchip technology inc. advance information ds41211a-page 49 PIC12F683 8.0 capture/compare/pwm (ccp) module the capture/compare/pwm (ccp) module contains a 16-bit register which can operate as a:  16-bit capture register  16-bit compare register  pwm master/slave duty cycle register capture/compare/pwm register1 (ccpr1) is comprised of two 8-bit registers: ccpr1l (low byte) and ccpr1h (high byte). the ccp1con register controls the operation of ccp. the special event trigger is generated by a compare match and will clear both tmr1h and tmr1l registers. table 8-1: ccp mode - timer resources required register 8-1: ccp1con ? capture/compare/pwm register (address: 15h) ccp mode timer resource capture compare pwm timer1 timer1 timer2 u-0 u-0 r/w-0 r/w-0 r/w-0 r/w-0 r/w-0 r/w-0 ? ? dc1b1 dc1b0 ccp1m3 ccp1m2 ccp1m1 ccp1m0 bit 7 bit 0 bit 7-6 unimplemented: read as ? 0 ? bit 5-4 dc1b1:dc1b0 : pwm least significant bits capture mode : unused compare mode: unused pwm mode: these bits are the two lsbs of the pwm duty cycle. the eight msbs are found in ccpr1l. bit 3-0 ccp1m3:ccp1m0 : ccp1 mode select bits 0000 = capture/compare/pwm disabled (resets ccp1 module) 0100 = capture mode, every falling edge 0101 = capture mode, every rising edge 0110 = capture mode, every 4th rising edge 0111 = capture mode, every 16th rising edge 1000 = compare mode, set output on match (ccp1if bit is set) 1001 = compare mode, clear output on match (ccp1if bit is set) 1010 = compare mode, generate software interrupt on match (ccp1if bit is set, ccp1 pin is unaffected) 1011 = compare mode, trigger special event (ccp1if bit is set, ccp1 pin is unaffected); ccp1 resets tmr1 and starts an a/d conversion (if a/d module is enabled) 11xx =pwm mode legend: r = readable bit w = writable bit u = unimplemented bit, read as ?0? - n = value at por ?1? = bit is set ?0? = bit is cleared x = bit is unknown
PIC12F683 ds41211a-page 50 advance information ? 2003 microchip technology inc. 8.1 capture mode in capture mode, ccpr1h:ccpr1l captures the 16-bit value of the tmr1 register when an event occurs on pin gp2/an2/t0cki/int/cout. an event is defined as one of the following and is configured by ccp1con<3:0>:  every falling edge  every rising edge  every 4th rising edge  every 16th rising edge when a capture is made, the interrupt request flag bit ccp1if (pir1<5>) is set. the interrupt flag must be cleared in software. if another capture occurs before the value in register ccpr1 is read, the old captured value is overwritten by the new captured value. 8.1.1 ccp1 pin configuration in capture mode, the gp2/an2/t0cki/int/cout pin should be configured as an input by setting the trisio<2> bit. figure 8-1: capture mode operation block diagram 8.1.2 timer1 mode selection timer1 must be running in timer mode or synchro- nized counter mode for the ccp module to use the capture feature. in asynchronous counter mode, the capture operation may not work. 8.1.3 software interrupt when the capture mode is changed, a false capture interrupt may be generated. the user should keep bit ccp1ie (pie1<5>) clear to avoid false interrupts and should clear the flag bit ccp1if following any such change in operating mode. 8.1.4 ccp prescaler there are four prescaler settings specified by bits ccp1m3:ccp1m0 (ccp1con<3:0>). whenever the ccp module is turned off, or the ccp module is not in capture mode, the prescaler counter is cleared. any reset will clear the prescaler counter. switching from one capture prescaler to another may generate an interrupt. also, the prescaler counter will not be cleared, therefore, the first capture may be from a non-zero prescaler. example 8-1 shows the recom- mended method for switching between capture prescalers. this example also clears the prescaler counter and will not generate the ?false? interrupt. example 8-1: changing between capture prescalers note: if the gp2/an2/t0cki/int/cout pin is configured as an output, a write to the port can cause a capture condition. ccpr1h ccpr1l tmr1h tmr1l set flag bit ccp1if (pir1<5>) capture enable q?s ccp1con<3:0> gp2/ccp1 prescaler 1, 4, 16 and edge detect pin clrf ccp1con ;turn ccp module off movlw new_capt_ps ;load the w reg with ;the new prescaler ;move value and ccp on movwf ccp1con ;load ccp1con with this ;value
? 2003 microchip technology inc. advance information ds41211a-page 51 PIC12F683 8.2 compare mode in compare mode, the 16-bit ccpr1 register value is constantly compared against the tmr1 register pair value. when a match occurs, the gp2/an2/t0cki/int/ cout pin is:  driven high driven low  remains unchanged the action on the pin is based on the value of control bits ccp1m3:ccp1m0 (ccp1con<3:0>). at the same time, interrupt flag bit ccp1if (pir1<5>) is set. figure 8-2: compare mode operation block diagram 8.2.1 ccp1 pin configuration the user must configure the gp2/an2/t0cki/int/ cout pin as an output by clearing the trisio<2> bit. 8.2.2 timer1 mode selection timer1 must be running in timer mode or synchro- nized counter mode if the ccp module is using the compare feature. in asynchronous counter mode, the compare operation may not work. 8.2.3 software interrupt mode when generate software interrupt mode is chosen (ccp1m<3:0> = 1010), the ccp1 pin is not affected. the ccp1if (pir1<5>) bit is set, causing a ccp interrupt (if enabled). see register 8-1. 8.2.4 special event trigger in this mode, an internal hardware trigger is generated, which may be used to initiate an action. the special event trigger output of ccp1 resets the tmr1 register pair and starts a/d conversion, if enabled. this allows the ccpr1 register to effectively be a 16-bit programmable period register for timer1. table 8-2: registers associated with capture, compare, and timer1 ccpr1h ccpr1l tmr1h tmr1l comparator qs r output logic special event trigger set flag bit ccp1if (pir1<5>) match gp2/ccp1 trisio<2> ccp1con<3:0> mode select output enable pin special event trigger will:  clear tmr1h and tmr1l registers  not set interrupt flag bit tmr1f (pir1<0>)  set the go/done bit (adcon0<1>) note: clearing the ccp1con register will force the gp2/an2/t0cki/int/cout compare output latch to the default low level. this is not the gpio data latch. note: the special event trigger from the ccp1 modules will not set interrupt flag bit tmr1if (pir1<0>). addr name bit 7 bit 6 bit 5 bit 4 bit 3 bit 2 bit 1 bit 0 value on por, bod value on all other resets 0bh/ 8bh intcon gie peie t0ie inte gpie t0if intf gpif 0000 0000 0000 0000 0ch pir1 eeif adif ccp1if ? cmif osfif tmr2if tmr1if 000- 0000 000- 0000 0eh tmr1l holding register for the least significant byte of the 16-bit tmr1 register xxxx xxxx uuuu uuuu 0fh tmr1h holding register for the most significant byte of the 16-bit tmr1 register xxxx xxxx uuuu uuuu 10h t1con t1ginv tmr1ge t1ckps1 t1ckps0 t1oscen t1sync tmr1cs tmr1on 0000 0000 uuuu uuuu 1ah cmcon1 ? ? ? ? ? ?t1gss cmsync ---- --10 ---- --10 13h ccpr1l capture/compare/pwm register1 low byte xxxx xxxx uuuu uuuu 14h ccpr1h capture/compare/pwm register1 high byte xxxx xxxx uuuu uuuu 15h ccp1con p1m1 p1m0 dc1b1 dc1b0 ccp1m3 ccp1m2 ccp1m1 ccp1m0 0000 0000 0000 0000 8ch pie1 eeie adie ccp1ie ? cmie osfie tmr2ie tmr1ie 000- 0000 000- 0000 legend: ? = unimplemented locations, read as ? 0 ?, u = unchanged, x = unknown. shaded cells are not used by the capture, compare or timer1 module.
PIC12F683 ds41211a-page 52 advance information ? 2003 microchip technology inc. 8.3 pwm mode (pwm) in pulse width modulation mode, the ccp1 pin produces up to a 10-bit resolution pwm output. since the ccp1 pin is multiplexed with the gpio data latch, the trisio<2> bit must be cleared to make the ccp1 pin an output. figure 8-3 shows a simplified block diagram of the ccp module in pwm mode. for a step-by-step procedure on how to set up the ccp module for pwm operation, see section 8.3.3 ?setup for pwm operation? . figure 8-3: simplified pwm block diagram a pwm output (figure 8-4) has a time base (period) and a time that the output stays high (duty cycle). the frequency of the pwm is the inverse of the period (1/period). figure 8-4: pwm output 8.3.1 pwm period the pwm period is specified by writing to the pr2 register. the pwm period can be calculated using the following formula. equation 8-1: pwm frequency is defined as 1/[pwm period]. when tmr2 is equal to pr2, the following three events occur on the next increment cycle:  tmr2 is cleared.  the ccp1 pin is set (exception: if pwm duty cycle = 0%, the ccp1 pin will not be set).  the pwm duty cycle is latched from ccpr1l into ccpr1h. note: clearing the ccp1con register will force the ccp1 pwm output latch to the default low level. this is not the gpio data latch. ccpr1l ccpr1h (slave) comparator tmr2 comparator pr2 (note 1) r q s duty cycle registers ccp1con<5:4> clear timer, ccp1 pin and latch d.c. trisio<2> gp2/ccp1 note 1: the 8-bit timer is concatenated with 2-bit internal q clock, or 2 bits of the prescaler, to create 10-bit time base. period duty cycle tmr2 = pr2 tmr2 = duty cycle tmr2 = pr2 note: the timer2 postscaler (see section 7.1 ?timer2 operation? ) is not used in the determination of the pwm frequency. the postscaler could be used to have a servo update rate at a different frequency than the pwm output. pwm period pr2 () 1 + [] 4t osc tmr2 prescale value ? ? ? =
? 2003 microchip technology inc. advance information ds41211a-page 53 PIC12F683 8.3.2 pwm duty cycle the pwm duty cycle is specified by writing to the ccpr1l register and to the ccp1con<5:4> bits. up to 10-bit resolution is available. the ccpr1l contains the eight msbs and the ccp1con<5:4> contains the two lsbs. this 10-bit value is represented by ccpr1l:ccp1con<5:4>. the following equation is used to calculate the pwm duty cycle in time. equation 8-2: ccpr1l and ccp1con<5:4> can be written to at any time, but the duty-cycle value is not latched into ccpr1h until after a match between pr2 and tmr2 occurs (i.e., the period is complete). in pwm mode, ccpr1h is a read-only register. the ccpr1h register and a 2-bit internal latch are used to double buffer the pwm duty cycle. this double buffering is essential for glitch-free pwm operation. when the ccpr1h and 2-bit latch match tmr2, concatenated with an internal 2-bit q clock, or 2 bits of the tmr2 prescaler, the ccp1 pin is cleared. the maximum pwm resolution (bits) for a given pwm frequency is given by the following formula. equation 8-3: 8.3.3 setup for pwm operation the following steps should be taken when configuring the ccp1 module for pwm operation: 1. set the pwm period by writing to the pr2 register. 2. set the pwm duty cycle by writing to the ccpr1l register and ccp1con<5:4> bits. 3. make the ccp1 pin an output by clearing the trisio<2> bit. 4. set the tmr2 prescale value and enable timer2 by writing to t2con. 5. configure the ccp1 module for pwm operation. table 8-3: example pwm frequencies and resolutions at 20 mhz tmr2 prescale value ? pwm duty cycle ccpr1l:ccp1con<5:4> () t osc ? = note: if the pwm duty cycle value is longer than the pwm period, the ccp1 pin will not be cleared. note: the pwm module may generate a prema- ture pulse when changing the duty cycle. for sensitive applications, disable the pwm module prior to modifying the duty cycle. resolution f osc f pwm tm r2 prescale value ? ---------------------------------------------------------------------------- - ?? ?? log 2 () log ------------------------------------------------------------------------------------------ - bits = pwm frequency 1.22 khz 4.88 khz 19.53 khz 78.12khz 156.3 khz 208.3 khz timer prescaler (1, 4, 16) 16 4 1 1 1 1 pr2 value 0xffh 0xffh 0xffh 0x3fh 0x1fh 0x17h maximum resolution (bits) 10 10 10 8 7 6.6
PIC12F683 ds41211a-page 54 advance information ? 2003 microchip technology inc. table 8-4: registers associated with pwm and timer2 addr name bit 7 bit 6 bit 5 bit 4 bit 3 bit 2 bit 1 bit 0 value on por, bod value on all other resets 0bh/ 8bh intcon gie peie t0ie inte gpie t0if intf gpif 0000 0000 0000 0000 0ch pir1 eeif adif ccp1if ? cmif osfif tmr2if tmr1if 000- 0000 000- 0000 11h tmr2 timer2 module register 0000 0000 0000 0000 12h t2con ? toutps3 toutps2 toutps1 toutps0 tmr2on t2ckps1 t2ckps0 -000 0000 -000 0000 13h ccpr1l capture/compare/pwm register1 low byte xxxx xxxx uuuu uuuu 14h ccpr1h capture/compare/pwm register1 high byte xxxx xxxx uuuu uuuu 15h ccp1con p1m1 p1m0 dc1b1 dc1b0 ccp1m3 ccp1m2 ccp1m1 ccp1m0 0000 0000 0000 0000 8ch pie1 eeie adie ccp1ie ? cmie osfie tmr2ie tmr1ie 000- 0000 000- 0000 92h pr2 timer2 module period register 1111 1111 1111 1111 legend: ? = unimplemented locations, read as ? 0 ?, u = unchanged, x = unknown. shaded cells are not used by the pwm or timer2 module.
? 2003 microchip technology inc. advance information ds41211a-page 55 PIC12F683 9.0 comparator module the comparator module contains one analog compara- tor. the inputs to the comparator are multiplexed with i/o port pins gp0 and gp1 while the outputs are multiplexed to gp2. an on-chip comparator voltage reference (cv ref ) can be also be applied to the inputs of the comparator. the cmcon0 register (register 9-1) controls the comparator input and output multiplexers. a block diagram of the various comparator configurations is shown in figure 9-3. register 9-1: cmcon0 ? comparator co nfiguration register (address: 19h) u-0 r-0 u-0 r/w-0 r/w-0 r/w-0 r/w-0 r/w-0 ?cout ?cinvciscm2cm1cm0 bit 7 bit 0 bit 7: unimplemented : read as ? 0 ? bit 6 cout : comparator output bit when cinv = 0 : 1 = v in + > v in - 0 = v in + < v in - when cinv = 1 : 1 = v in + < v in - 0 = v in + > v in - bit 5: unimplemented : read as ? 0 ? bit 4 cinv : comparator output inversion bit 1 = output inverted 0 = output not inverted bit 3 cis : comparator input switch bit when cm2:cm0 = 110 or 101: 1 = v in - connects to cin+ 0 = v in - connects to cin- bit 2 cm2:cm0 : comparator mode bits figure 9-3 shows the comparator modes and cm2:cm0 bit settings legend: r = readable bit w = writable bit u = unimplemented bit, read as ?0? - n = value at por ?1? = bit is set ?0? = bit is cleared x = bit is unknown
PIC12F683 ds41211a-page 56 advance information ? 2003 microchip technology inc. 9.1 comparator operation a single comparator is shown in figure 9-1 along with the relationship between the analog input levels and the digital output. when the analog input at v in + is less than the analog input v in -, the output of the comparator is a digital low level. when the analog input at v in + is greater than the analog input v in -, the output of the comparator is a digital high level. the shaded areas of the output of the comparator in figure 9-1 represent the uncertainty due to input offsets and response time. the polarity of the comparator output can be inverted by setting the cinv bit (cmcon0<4>). clearing cinv results in a non-inverted output. a complete table showing the output state versus input conditions and the polarity bit is shown in table 9-1. table 9-1: output state vs. input conditions figure 9-1: single comparator 9.2 analog input connection considerations a simplified circuit for an analog input is shown in figure 9-2. since the analog pins are connected to a digital output, they have reverse biased diodes to v dd and v ss . the analog input, therefore, must be between v ss and v dd . if the input voltage deviates from this range by more than 0.6v in either direction, one of the diodes is forward biased and a latch-up may occur. a maximum source impedance of 10 k  is recommended for the analog sources. any external component connected to an analog input pin, such as a capacitor or a zener diode, should have very little leakage current. figure 9-2: analog input model note: to use cin+ and cin- pins as analog inputs, the appropriate bits must be programmed in the cmcon0 (19h) regis- ter. input conditions cinv cout v in - > v in + 00 v in - < v in + 01 v in - > v in + 11 v in - < v in + 10 note 1: when reading the gpio register, all pins configured as analog inputs will read as a ? 0 ?. pins configured as digital inputs will convert as an analog input, according to the input specification. 2: analog levels on any pin defined as a digital input, may cause the input buffer to consume more current than is specified. ? + v in + v in - output v in? v in+ o utput output v in + v in - va rs < 10k a in c pin 5 pf v dd v t = 0.6v v t = 0.6v r ic leakage 500 na vss legend: c pin = input capacitance v t = threshold voltage i leakage = leakage current at the pin due to various junctions r ic = interconnect resistance r s = source impedance va = analog voltage
? 2003 microchip technology inc. advance information ds41211a-page 57 PIC12F683 9.3 comparator configuration there are eight modes of operation for the comparator. the cmcon0 register is used to select these modes. figure 9-3 shows the eight possible modes. the trisio register controls the data direction of the comparator pins for each mode. if the comparator mode is changed, the comparator output level may not be valid for the specified mode change delay shown in section 15.0 ?electrical specifications? . figure 9-3: comparator i/o operating modes note: comparator interrupts should be disabled during a comparator mode change. otherwise, a false interrupt may occur. comparator reset (por default value - low power) comparator off (lowest power) cm2:cm0 = 000 cm2:cm0 = 111 comparator without output comparator w/o output and with internal reference cm2:cm0 = 010 cm2:cm0 = 100 comparator with output and internal reference mul tiplexed input with internal reference and output cm2:cm0 = 011 cm2:cm0 = 101 comparator with output multiplexed input with internal reference cm2:cm0 = 001 cm2:cm0 = 110 a = analog input, ports always reads ? 0 ? d = digital input cis = comparator input switch (cmcon0<3>) gp1/cin- gp0/cin+ off (read as ?0?) a a gp2/cout d gp1/cin- gp0/cin+ off (read as ?0?) d d gp2/cout d gp1/cin- gp0/cin+ cout a a gp2/cout d gp1/cin- gp0/cin+ cout a d gp2/cout d from cv ref module gp1/cin- gp0/cin+ cout a d gp2/cout d from cv ref module gp1/cin- gp0/cin+ cout a a gp2/cout d from cv ref module cis = 0 cis = 1 gp1/cin- gp0/cin+ cout a a gp2/cout d gp1/cin- gp0/cin+ cout a a gp2/cout d from cv ref module cis = 0 cis = 1
PIC12F683 ds41211a-page 58 advance information ? 2003 microchip technology inc. figure 9-4: comparator output block diagram cmsync d q en to cout pin rd cmcon set cmif bit multiplex d q en cl port pins rd cmcon reset to data bus cinv d q en tmr1 clock source (1) 0 1 to t m r 1 note 1: comparator output is latched on fa lling edge of t1 clock source.
? 2003 microchip technology inc. advance information ds41211a-page 59 PIC12F683 register 9-2: cmcon1 ? comparator configuration register (address: 1ah) 9.4 comparator output the comparator output is read through the cmcon0 register. this bit is read-only. the comparator output may also be directly output to the gp2 pin. when enabled, multiplexors in the output path of the gp2 pin will switch and the output will be the unsynchronized output of the comparator. the uncertainty of the comparator is related to the input offset voltage and the response time given in the specifications. figure 9-4 shows the output block diagram for the comparator. the trisio bit will still function as an output enable/disable for the gp2 pin while in this mode. the polarity of the comparator outputs can be changed using the cinv bit (cmcon0<4>). timer1 gate source can be configured to use the t1g pin or the comparator output as selected by the t1gss bit (cmcon1<1>). this feature can be used to time the duration or interval of analog events. the output of the comparator can also be synchronized with timer1 by setting the cmsync bit (cmcon1<0>). when enabled, the output of comparator is latched on the falling edge of timer1 clock source. if a prescaler is used with timer1, the comparator is latched after the prescaler. to prevent a race condition, the comparator output is latched on the falling edge of the timer1 clock source and timer1 increments on the rising edge of its clock source. see the comparator block diagram (figure 9-4) and the timer1 block diagram (figure 6-1) for more information. it is recommended to synchronize the comparator with timer1 by setting the cmsync bit when the compara- tor is used as the timer1 gate source. this ensures timer1 does not miss an increment if the comparator changes during an increment. 9.5 comparator interrupt the comparator interrupt flag is set whenever there is a change in the output value of the comparator. software will need to maintain information about the status of the output bit, as read from cmcon0<6>, to determine the actual change that has occurred. the cmif bit, pir1<3>, is the comparator interrupt flag. this bit must be reset in software by clearing it to ? 0 ?. since it is also possible to write a '1' to this register, a simulated interrupt may be initiated. the cmie bit (pie1<3>) and the peie bit (intcon<6>) must be set to enable the interrupts. in addition, the gie bit must also be set. if any of these bits are cleared, the interrupt is not enabled, though the cmif bit will still be set if an interrupt condition occurs. the user, in the interrupt service routine, can clear the interrupt in the following manner: a) any read or write of cmcon0. this will end the mismatch condition. b) clear flag bits cmif. a mismatch condition will continue to set flag bits cmif. reading cmcon0 will end the mismatch condition and allow flag bits cmif to be cleared. u-0 u-0 u-0 u-0 u-0 u-0 r/w-1 r/w-0 ? ? ? ? ? ? t1gss cmsync bit 7 bit 0 bit 7-2: unimplemented : read as ? 0 ? bit 1 t1gss: timer 1 gate source select bit 1 = timer 1 gate source is t1g pin (gp4 must be configured as digital input) 0 = timer 1 gate source is comparator output bit 0 cmsync: comparator synchronize bit 1 = cout output synchronized with falling edge of timer 1 clock 0 = cout output not synchronized with timer 1 clock legend: r = readable bit w = writable bit u = unimplemented bit, read as ?0? - n = value at por ?1? = bit is set ?0? = bit is cleared x = bit is unknown note: if a change in the cmcon0 register (cout) should occur when a read operation is being executed (start of the q2 cycle), then the cmif (pir1<3>) inter- rupt flags may not get set.
PIC12F683 ds41211a-page 60 advance information ? 2003 microchip technology inc. 9.6 comparator reference the comparator module also allows the selection of an internally generated voltage reference for one of the comparator inputs. the vrcon register, register 9-3, controls the voltage reference module shown in figure 9-5. 9.6.1 configuring the voltage reference the voltage reference can output 32 distinct voltage levels, 16 in a high range and 16 in a low range. the following equations determine the output voltages: equation 9-1: 9.6.2 voltage reference accuracy/error the full range of v ss to v dd cannot be realized due to the construction of the module. the transistors on the top and bottom of the resistor ladder network (figure 9-5) keep cv ref from approaching v ss or v dd . the exception is when the module is disabled by clearing the v ren bit (vrcon<7>). when disabled, the reference voltage is v ss when vr<3:0> is ? 0000 ? and the v rr (vrcon<5>) bit is set. this allows the comparator to detect a zero-crossing and not consume cv ref module current. the voltage reference is v dd derived and therefore, the cv ref output changes with fluctuations in v dd . the tested absolute accuracy of the comparator voltage reference can be found in section 15.0 ?electrical specifications? . figure 9-5: comparator voltage reference block diagram v rr 1 (low range): cvref (vr3:vr0/24) v dd == v rr 0 (high range): = cv ref (v dd /4) + (vr3:vr0 x v dd /32) = vrr 8r vr3:vr0 16-1 analog 8rrr rr cv ref to 16 stages comparator input v ren v dd mux vr3:vr0 = ? 0000 ? v ren vrr
? 2003 microchip technology inc. advance information ds41211a-page 61 PIC12F683 9.7 comparator response time response time is the minimum time, after selecting a new reference voltage or input source, before the comparator output is ensured to have a valid level. if the internal reference is changed, the maximum delay of the internal voltage reference must be considered when using the comparator output. otherwise, the maximum delay of the comparator should be used (table 15-8). 9.8 operation during sleep the comparator and voltage reference, if enabled before entering sleep mode, remain active during sleep. this results in higher sleep currents than shown in the power-down specifications. the additional current consumed by the comparator and the voltage reference is shown separately in the specifications. to minimize power consumption while in sleep mode, turn off the comparator, cm2:cm0 = 111 , and voltage reference, vrcon<7> = 0. while the comparator is enabled during sleep, an inter- rupt will wake-up the device. if the gie bit (intcon<7>) is set, the device will jump to the inter- rupt vector (0004h), and if clear, continues execution with the next instruction. if the device wakes up from sleep, the contents of the cmcon0, cmcon1 and vrcon registers are not affected. 9.9 effects of a reset a device reset forces the cmcon0, cmcon1 and vrcon registers to their reset states. this forces the comparator module to be in the comparator reset mode, cm2:cm0 = 000 and the voltage reference to its off state. thus, all potential inputs are analog inputs with the comparator and voltage reference disabled to consume the smallest current possible.
PIC12F683 ds41211a-page 62 advance information ? 2003 microchip technology inc. register 9-3: vrcon ? voltage reference control register (address: 99h) table 9-2: registers associated with comparator module r/w-0 u-0 r/w-0 r/w-0 r/w-0 r/w-0 r/w-0 r/w-0 vren ?vrr ? vr3 vr2 vr1 vr0 bit 7 bit 0 bit 7 vren: cv ref enable bit 1 = cv ref circuit powered on 0 = cv ref circuit powered down, no i dd drain and cv ref = v ss . bit 6 unimplemented: read as ?0? bit 5 vrr: cv ref range selection bit 1 = low range 0 = high range bit 4 unimplemented: read as ?0? bit 3-0 vr3:vr0: cv ref value selection 0  vr [3:0]  15 when vrr = 1: cv ref = (vr3:vr0 / 24) * v dd when vrr = 0: cv ref = v dd /4 + (vr3:vr0 / 32) * v dd legend: r = readable bit w = writable bit u = unimplemented bit, read as ?0? - n = value at por ?1? = bit is set ?0? = bit is cleared x = bit is unknown address name bit 7 bit 6 bit 5 bit 4 bit 3 bit 2 bit 1 bit 0 value on por, bod value on all other resets 0bh/8bh intcon gie peie t0ie inte gpie t0if intf gpif 0000 0000 0000 0000 0ch pir1 eeif adif ccp1if ?cmif osfif tmr2if tmr1if 000- 0000 000- 0000 19h cmcon0 ?cout ? cinv cis cm2 cm1 cm0 -0-0 0000 -0-0 0000 1ah cmcon1 ? ? ? ? ? ? t1gss cmsync ---- --10 ---- --10 85h trisio ? ? trisio5 trisio4 trisio3 trisio2 trisio1 trisio0 --11 1111 --11 1111 8ch pie1 eeie adie ccpie ? cmie osfie tmr2ie tmr1ie 000- 0000 000- 0000 99h vrcon vren ?vrr ? vr3 vr2 vr1 vr0 0-0- 0000 0-0- 0000 legend: x = unknown, u = unchanged, ? = unimplemented, read as ? 0 ?. shaded cells are not used by the comparator or comparator voltage reference module.
? 2003 microchip technology inc. advance information ds41211a-page 63 PIC12F683 10.0 analog-to-digital converter (a/d) module the analog-to-digital converter (a/d) allows conversion of an analog input signal to a 10-bit binary representa- tion of that signal. the PIC12F683 has four analog inputs, multiplexed into one sample and hold circuit. the output of the sample and hold is connected to the input of the converter. the converter generates a binary result via successive approximation and stores the result in a 10-bit register. the voltage reference used in the conversion is software selectable to either v dd or a voltage applied by the v ref pin. figure 10-1 shows the block diagram of the a/d on the PIC12F683. figure 10-1: a/d block diagram 10.1 a/d configuration and operation there are two registers available to control the functionality of the a/d module: 1. adcon0 (register 10-1) 2. ansel (register 10-2) 10.1.1 analog port pins the ans3:ans0 bits (ansel<3:0>) and the trisio bits control the operation of the a/d port pins. set the corresponding trisio bits to set the pin output driver to its high-impedance state. likewise, set the corre- sponding ansel bit to disable the digital input buffer. 10.1.2 channel selection there are four analog channels on the PIC12F683, an0 through an3. the chs2:chs0 bits (adcon0<4:2>) control which channel is connected to the sample and hold circuit. 10.1.3 voltage reference there are two options for the voltage reference to the a/d converter: either v dd is used, or an analog voltage applied to v ref is used. the vcfg bit (adcon0<6>) controls the voltage reference selection. if vcfg is set, then the voltage on the v ref pin is the reference; otherwise, v dd is the reference. gp0/an0 a/d gp1/an1/v ref gp2/an2 v dd v ref adon go/done vcfg = 1 vcfg = 0 chs2:chs0 adresh adresl 10 10 adfm v ss gp4/an3 note: analog voltages on any pin that is defined as a digital input may cause the input buffer to conduct excess current.
PIC12F683 ds41211a-page 64 advance information ? 2003 microchip technology inc. 10.1.4 conversion clock the a/d conversion cycle requires 11 t ad . the source of the conversion clock is software selectable via the adcs bits (ansel<6:4>). there are seven possible clock options: f osc /2 f osc /4 f osc /8 f osc /16 f osc /32 f osc /64 f rc (dedicated internal oscillator) for correct conversion, the a/d conversion clock (1/t ad ) must be selected to ensure a minimum t ad of 1.6 s. table 10-1 shows a few t ad calculations for selected frequencies. table 10-1: t ad vs. device operating frequencies a/d clock source (t ad ) device frequency operation adcs2:adcs0 20 mhz 5 mhz 4 mhz 1.25 mhz 2 t osc 000 100 ns (2) 400 ns (2) 500 ns (2) 1.6 s 4 t osc 100 200 ns (2) 800 ns (2) 1.0 s (2) 3.2 s 8 t osc 001 400 ns (2) 1.6 s2.0 s6.4 s 16 t osc 101 800 ns (2) 3.2 s4.0 s 12.8 s (3) 32 t osc 010 1.6 s6.4 s 8.0 s (3) 25.6 s (3) 64 t osc 110 3.2 s 12.8 s (3) 16.0 s (3) 51.2 s (3) a/d rc x11 2 - 6 s (1,4) 2 - 6 s (1,4) 2 - 6 s (1,4) 2 - 6 s (1,4) legend: shaded cells are outside of recommended range. note 1: the a/d rc source has a typical t ad time of 4 s for v dd > 3.0v. 2: these values violate the minimum required t ad time. 3: for faster conversion times, the selection of another clock source is recommended. 4: when the device frequency is greater than 1 mhz, the a/d rc clock source is only recommended if the conversion will be performed during sleep.
? 2003 microchip technology inc. advance information ds41211a-page 65 PIC12F683 10.1.5 starting a conversion the a/d conversion is initiated by setting the go/done bit (adcon0<1>). when the conversion is complete, the a/d module:  clears the go/done bit  sets the adif flag (pir1<6>)  generates an interrupt (if enabled) if the conversion must be aborted, the go/done bit can be cleared in software. the adresh:adresl registers will not be updated with the partially complete a/d conversion sample. instead, the adresh:adresl registers will retain the value of the previous conversion. after an aborted conversion, a 2t ad delay is required before another acquisition can be initiated. following the delay, an input acquisition is automatically started on the selected channel. figure 10-2: a/d conversion t ad cycles 10.1.6 conversion output the a/d conversion can be supplied in two formats: left or right shifted. the adfm bit (adcon0<7>) controls the output format. figure 10-3 shows the output formats. figure 10-3: 10-bit a/d result format note: the go/done bit should not be set in the same instruction that turns on the a/d. t ad 1 t ad 2 t ad 3 t ad 4 t ad 5 t ad 6 t ad 7 t ad 8 t ad 9 set go bit holding capacitor is disconnected fr om analog input (typically 100 ns) b9 b8 b7 b6 b5 b4 b3 b2 t ad 10 t ad 11 b1 b0 t cy to t ad conversion starts adresh and adresl registers are loaded, go bit is cleared, adif bit is set, holding capacitor is connected to analog input adresh adresl (adfm = 0) msb lsb bit 7bit 0bit 7bit 0 10-bit a/d result unimplemented: read as ? 0 ? (adfm = 1) msb lsb bit 7bit 0bit 7bit 0 unimplemented: read as ?0? 10-bit a/d result
PIC12F683 ds41211a-page 66 advance information ? 2003 microchip technology inc. register 10-1: adcon0 ? a/d control register (address: 1fh) r/w-0 r/w-0 u-0 r/w-0 r/w-0 r/w-0 r/w-0 r/w-0 adfm vcfg ? chs2 chs1 chs0 go/done adon bit 7 bit 0 bit 7 adfm: a/d result formed select bit 1 = right justified 0 = left justified bit 6 vcfg: voltage reference bit 1 = v ref pin 0 = v dd bit 5 unimplemented: read as zero bit 4-2 chs2:chs0: analog channel select bits 000 = channel 00 (an0) 001 = channel 01 (an1) 010 = channel 02 (an2) 011 = channel 03 (an3) bit 1 go/done : a/d conversion status bit 1 = a/d conversion cycle in progress. setting this bit starts an a/d conversion cycle. this bit is automatically cleared by hardware when the a/d conversion has completed. 0 = a/d conversion completed/not in progress bit 0 adon: a/d conversion status bit 1 = a/d converter module is operating 0 = a/d converter is shut-off and consumes no operating current legend: r = readable bit w = writable bit u = unimplemented bit, read as ?0? - n = value at por ?1? = bit is set ?0? = bit is cleared x = bit is unknown
? 2003 microchip technology inc. advance information ds41211a-page 67 PIC12F683 register 10-2: ansel ? analog select register (address: 9fh) u-0 r/w-0 r/w-0 r/w-0 r/w-1 r/w-1 r/w-1 r/w-1 ? adcs2 adcs1 adcs0 ans3 ans2 ans1 ans0 bit 7 bit 0 bit 7: unimplemented: read as ? 0 ? bit 6-4: adcs<2:0>: a/d conversion clock select bits 000 =f osc /2 001 =f osc /8 010 =f osc /32 x11 =f rc (clock derived from a dedicated internal oscillator = 500 khz max) 100 =f osc /4 101 =f osc /16 110 =f osc /64 bit 3-0: ans<3:0> : analog select bits analog select between analog or digital function on pins an<3:0>, respectively. 1 = analog input. pin is assigned as analog input. (1) 0 = digital i/o. pin is assigned to port or special function. note 1: setting a pin to an analog input automatically disables the digital input circuitry, weak pull-ups, and interrupt-on-change if available. the corresponding trisio bit must be set to input mode in order to allow external control of the voltage on the pin. legend: r = readable bit w = writable bit u = unimplemented bit, read as ?0? - n = value at por ?1? = bit is set ?0? = bit is cleared x = bit is unknown
PIC12F683 ds41211a-page 68 advance information ? 2003 microchip technology inc. 10.1.7 configuring the a/d after the a/d module has been configured as desired, the selected channel must be acquired before the conversion is started. the analog input channels must have their corresponding trisio bits selected as inputs. to determine sample time, see section 15.0 ?electri- cal specifications? . after this sample time has elapsed the a/d conversion can be started. these steps should be followed for an a/d conversion: 1. configure the a/d module:  configure analog/digital i/o (ansel)  configure voltage reference (adcon0)  select a/d input channel (adcon0)  select a/d conversion clock (ansel)  turn on a/d module (adcon0) 2. configure a/d interrupt (if desired):  clear adif bit (pir1<6>)  set adie bit (pie1<6>)  set peie and gie bits (intcon<7:6>) 3. wait the required acquisition time. 4. start conversion:  set go/done bit (adcon0<0>) 5. wait for a/d conversion to complete, by either:  polling for the go/done bit to be cleared (with interrupts disabled); or  waiting for the a/d interrupt 6. read a/d result register pair (adresh:adresl), clear bit adif if required. 7. for next conversion, go to step 1 or step 2 as required. the a/d conversion time per bit is defined as t ad . a minimum wait of 2 t ad is required before the next acquisition starts. example 10-1: a/d conversion ;this code block configures the a/d ;for polling, vdd reference, r/c clock ;and gp0 input. ; ;conversion start & wait for complete ;polling code included. ; bsf status,rp0 ;bank 1 movlw b?01110001? ;a/d rc clock movwf ansel ;set gp0 to analog bsf trisio,0 ;set gp0 to input bcf status,rp0 ;bank 0 movlw b?10000001? ;right, vdd vref, an0 movwf adcon0 call sampletime ;wait min sample time bsf adcon0,go ;start conversion btfsc adcon0,go ;is conversion done? goto $-1 ;no, test again movf adresh,w ;read upper 2 bits movwf resulthi bsf status,rp0 ;bank 1 movf adresl,w ;read lower 8 bits movwf resultlo
? 2003 microchip technology inc. advance information ds41211a-page 69 PIC12F683 10.2 a/d acquisition requirements for the a/d converter to meet its specified accuracy, the charge holding capacitor (c hold ) must be allowed to fully charge to the input channel voltage level. the analog input model is shown in figure 10-4. the source impedance (r s ) and the internal sampling switch (r ss ) impedance directly affect the time required to charge the capacitor c hold . the sampling switch (r ss ) impedance varies over the device voltage (v dd ), see figure 10-4. the maximum recom- mended impedance for analog sources is 10 k  . as the impedance is decreased, the acquisition time may be decreased. after the analog input channel is selected (changed), this acquisition must be done before the conversion can be started. to calculate the minimum acquisition time, equation 10-1 may be used. this equation assumes that 1/2 lsb error is used (1024 steps for the a/d). the 1/2 lsb error is the maximum error allowed for the a/d to meet its specified resolution. to calculate the minimum acquisition time, t acq , see the picmicro ? mid-range reference manual (ds33023). equation 10-1: acquisition time figure 10-4: analog input model note 1: the reference voltage (v ref ) has no effect on the equation, since it cancels itself out. 2: the charge holding capacitor (c hold ) is not discharged after each conversion. 3: the maximum recommended impedance for analog sources is 10 k  . this is required to meet the pin leakage specification. t acq amplifier settling time hold capacitor charging time temperature coefficient ++ = t amp t c t coff ++ = 2s t c temperature - 25c () 0.05s/c () [] ++ = t c c hold r ic r ss r s ++ () in(1/2047) = -120pf 1k  7k  10k  ++ () in(0.0004885) = 16.47s = t acq 2 s 16.47 s 50c- 25c () 0.05 s /c () [] ++ = 19.72s = c pin va r s anx 5 pf v dd v t = 0.6v v t = 0.6v i leakage r ic  1k sampling switch ss r ss c hold = dac capacitance v ss 6v sampling switch 5v 4v 3v 2v 567891011 (k  ) v dd = 120 pf 500 na legend c pin v t i leakage r ic ss c hold = input capacitance = threshold voltage = leakage current at the pin due to = interconnect resistance = sampling switch = sample/hold capacitance (from dac) various junctions
PIC12F683 ds41211a-page 70 advance information ? 2003 microchip technology inc. 10.3 a/d operation during sleep the a/d converter module can operate during sleep. this requires the a/d clock source to be set to the internal oscillator. when the rc clock source is selected, the a/d waits one instruction before starting the conversion. this allows the sleep instruction to be executed, thus eliminating much of the switching noise from the conversion. when the conversion is complete, the go/done bit is cleared, and the result is loaded into the adresh:adresl registers. if the a/d interrupt is enabled, the device awakens from sleep. if the gie bit (intcon<7>) is set, the program counter is set the interrupt vector (0004h), if gie is clear, the next instruction is executed. if the a/d inter- rupt is not enabled, the a/d module is turned off, although the adon bit remains set. when the a/d clock source is something other than rc, a sleep instruction causes the present conversion to be aborted, and the a/d module is turned off. the adon bit remains set. figure 10-5: PIC12F683 a/d transfer function 3ffh 3feh a/d output code 3fdh 3fch 004h 003h 002h 001h 000h full-scale 3fbh 1 lsb ideal 0v zero-scale transition v ref transition 1 lsb ideal full-scale range analog input voltage
? 2003 microchip technology inc. advance information ds41211a-page 71 PIC12F683 10.4 effects of reset a device reset forces all registers to their reset state. thus, the a/d module is turned off and any pending conversion is aborted. the adresh:adresl registers are unchanged. table 10-2: summary of a/d registers addr name bit 7 bit 6 bit 5 bit 4 bit 3 bit 2 bit 1 bit 0 value on: por, bod value on all other resets 05h gpio ? ? gp5 gp4 gp3 gp2 gp1 gp0 --xx xxxx --uu uuuu 0bh/ 8bh intcon gie peie t0ie inte gpie t0if intf gpif 0000 0000 0000 0000 0ch pir1 eeif adif ccp1if ? cmif osfif tmr2if tmr1if 000- 0000 000- 0000 1eh adresh most significant 8 bits of the left shifted a/d result or 2 bits of the right shifted result xxxx xxxx uuuu uuuu 1fh adcon0 adfm vcfg ? chs2 chs1 chs0 go adon 00-0 0000 00-0 0000 85h trisio ? ? trisio5 trisio4 trisio3 trisio2 trisio1 trisio0 --11 1111 --11 1111 8ch pie1 eeie adie ccpie ? cmie osfie tmr2ie tmr1ie 000- 0000 000- 0000 9eh adresl least significant 2 bits of the left shifted a/d result or 8 bits of the right shifted result xxxx xxxx uuuu uuuu 9fh ansel ? adcs2 adcs1 adcs0 ans3 ans2 ans1 ans0 -000 1111 -000 1111 legend: x = unknown, u = unchanged, ? = unimplemented read as ? 0 ?. shaded cells are not used for a/d module.
PIC12F683 ds41211a-page 72 advance information ? 2003 microchip technology inc. notes:
? 2003 microchip technology inc. advance information ds41211a-page 73 PIC12F683 11.0 data eeprom memory the eeprom data memory is readable and writable during normal operation (full v dd range). this memory is not directly mapped in the register file space. instead, it is indirectly addressed through the special function registers. there are four sfrs used to read and write this memory:  eecon1  eecon2 (not a physically implemented register)  eedat  eeadr eedat holds the 8-bit data for read/write and eeadr holds the address of the eeprom location being accessed. PIC12F683 has 256 bytes of data eeprom with an address range from 0h to ffh. the eeprom data memory allows byte read and write. a byte write automatically erases the location and writes the new data (erase before write). the eeprom data memory is rated for high erase/write cycles. the write time is controlled by an on-chip timer. the write time will vary with voltage and temperature as well as from chip-to-chip. please refer to ac specifications in section 15.0 ?electrical specifications? for exact limits. when the data memory is code protected, the cpu may continue to read and write the data eeprom memory. the device programmer can no longer access the data eeprom data and will read zeroes. additional information on the data eeprom is available in the picmicro ? mid-range reference manual , (ds33023). register 11-1: eedat ? eeprom data register (address: 9ah) register 11-2: eeadr ? eeprom address register (address: 9bh) r/w-0 r/w-0 r/w-0 r/w-0 r/w-0 r/w-0 r/w-0 r/w-0 eedat7 eedat6 eedat5 eedat4 eedat3 eedat2 eedat1 eedat0 bit 7 bit 0 bit 7-0 eedatn : byte value to write to or read from data eeprom bits legend: r = readable bit w = writable bit u = unimplemented bit, read as ?0? - n = value at por ?1? = bit is set ?0? = bit is cleared x = bit is unknown r/w-0 r/w-0 r/w-0 r/w-0 r/w-0 r/w-0 r/w-0 r/w-0 eadr7 eadr6 eadr5 eadr4 eadr3 eadr2 eadr1 eadr0 bit 7 bit 0 bit 7-0 eeadr : specifies one of 256 locations for eeprom read/write operation bits legend: r = readable bit w = writable bit u = unimplemented bit, read as ?0? - n = value at por ?1? = bit is set ?0? = bit is cleared x = bit is unknown
PIC12F683 ds41211a-page 74 advance information ? 2003 microchip technology inc. 11.1 eecon1 and eecon2 registers eecon1 is the control register with four low-order bits physically implemented. the upper four bits are non- implemented and read as ? 0 ?s. control bits rd and wr initiate read and write, respectively. these bits cannot be cleared, only set in software. they are cleared in hardware at completion of the read or write operation. the inability to clear the wr bit in software prevents the accidental, premature termination of a write operation. the wren bit, when set, will allow a write operation. on power-up, the wren bit is clear. the wrerr bit is set when a write operation is interrupted by a mclr reset, or a wdt time-out reset during normal operation. in these situations, following reset, the user can check the wrerr bit, clear it, and rewrite the location. the data and address will be cleared. therefore, the eedat and eeadr registers will need to be re-initial- ized. interrupt flag eeif bit (pir1<7>) is set when write is complete. this bit must be cleared in software. eecon2 is not a physical register. reading eecon2 will read all ?0?s. the eecon2 register is used exclusively in the data eeprom write sequence. register 11-3: eecon1 ? eeprom control register (address: 9ch) note: the eecon1, eedat and eeadr registers should not be modified during a data eeprom write (wr bit = 1 ). u-0 u-0 u-0 u-0 r/w-x r/w-0 r/s-0 r/s-0 ? ? ? ? wrerr wren wr rd bit 7 bit 0 bit 7-4 unimplemented: read as ? 0 ? bit 3 wrerr: eeprom error flag bit 1 = a write operation is prematurely terminated (any mclr reset, any wdt reset during normal operation or bod detect) 0 = the write operation completed bit 2 wren: eeprom write enable bit 1 = allows write cycles 0 = inhibits write to the data eeprom bit 1 wr : write control bit 1 = initiates a write cycle (the bit is cleared by hardware once write is complete. the wr bit can only be set, not cleared, in software.) 0 = write cycle to the data eeprom is complete bit 0 rd : read control bit 1 = initiates an eeprom read (read takes one cycle. rd is cleared in hardware. the rd bit can only be set, not cleared, in software.) 0 = does not initiate an eeprom read legend: s = bit can only be set r = readable bit w = writable bit u = unimplemented bit, read as ?0? - n = value at por ?1? = bit is set ?0? = bit is cleared x = bit is unknown
? 2003 microchip technology inc. advance information ds41211a-page 75 PIC12F683 11.2 reading the eeprom data memory to read a data memory location, the user must write the address to the eeadr register and then set control bit rd (eecon1<0>), as shown in example 11-1. the data is available, in the very next cycle, in the eedat register. therefore, it can be read in the next instruction. eedat holds this value until another read, or until it is written to by the user (during a write operation). example 11-1: data eeprom read 11.3 writing to the eeprom data memory to write an eeprom data location, the user must first write the address to the eeadr register and the data to the eedat register. then the user must follow a specific sequence to initiate the write for each byte, as shown in example 11-2. example 11-2: data eeprom write the write will not initiate if the above sequence is not exactly followed (write 55h to eecon2, write aah to eecon2, then set wr bit) for each byte. we strongly recommend that interrupts be disabled during this code segment. a cycle count is executed during the required sequence. any number that is not equal to the required cycles to execute the required sequence will prevent the data from being written into the eeprom. additionally, the wren bit in eecon1 must be set to enable write. this mechanism prevents accidental writes to data eeprom due to errant (unexpected) code execution (i.e., lost programs). the user should keep the wren bit clear at all times, except when updating eeprom. the wren bit is not cleared by hardware. after a write sequence has been initiated, clearing the wren bit will not affect this write cycle. the wr bit will be inhibited from being set unless the wren bit is set. at the completion of the write cycle, the wr bit is cleared in hardware and the ee write complete interrupt flag bit (eeif) is set. the user can either enable this interrupt or poll this bit. the eeif bit (pir1<7>) register must be cleared by software. 11.4 write verify depending on the application, good programming practice may dictate that the value written to the data eeprom should be verified (see example 11-3) to the desired value to be written. example 11-3: write verify 11.4.1 using the data eeprom the data eeprom is a high-endurance, byte address- able array that has been optimized for the storage of frequently changing information (e.g., program variables or other data that are updated often). frequently changing values will typically be updated more often than specifications d120 or d120a. if this is not the case, an array refresh must be performed. for this reason, variables that change infrequently (such as constants, ids, calibration, etc.) should be stored in flash program memory. 11.5 protection against spurious write there are conditions when the user may not want to write to the data eeprom memory. to protect against spurious eeprom writes, various mechanisms have been built in. on power-up, wren is cleared. also, the power-up timer (64 ms duration) prevents eeprom write. the write initiate sequence and the wren bit together help prevent an accidental write during: brown-out  power glitch  software malfunction bsf status,rp0 ;bank 1 movlw config_addr ; movwf eeadr ;address to read bsf eecon1,rd ;ee read movf eedat,w ;move data to w bsf status,rp0 ;bank 1 bsf eecon1,wren ;enable write bcf intcon,gie ;disable ints movlw 55h ;unlock write movwf eecon2 ; movlw aah ; movwf eecon2 ; bsf eecon1,wr ;start the write bsf intcon,gie ;enable ints required sequence bsf status,rp0 ;bank 1 movf eedat,w ;eedat not changed ;from previous write bsf eecon1,rd ;yes, read the ;value written xorwf eedat,w btfss status,z ;is data the same goto write_err ;no, handle error : ;yes, continue
PIC12F683 ds41211a-page 76 advance information ? 2003 microchip technology inc. 11.6 data eeprom operation during code protect data memory can be code protected by programming the cpd bit in the configuration word (register 12-1) to ? 0 ?. when the data memory is code protected, the cpu is able to read and write data to the data eeprom. it is recommended to code protect the program memory when code protecting data memory. this prevents anyone from programming zeroes over the existing code (which will execute as nop s) to reach an added routine, programmed in unused program memory, which outputs the contents of data memory. programming unused locations in program memory to ? 0 ? will also help prevent data memory code protection from becoming breached. table 11-1: registers/bits associated with data eeprom address name bit 7 bit 6 bit 5 bit 4 bit 3 bit 2 bit 1 bit 0 value on por, bod value on all other resets 0bh/8bh intcon gie peie t0ie inte gpie t0if intf gpif 0000 0000 0000 0000 0ch pir1 eeif adif ccp1if ? cmif osfif tmr2if tmr1if 000- 0000 000- 0000 8ch pie1 eeie adie ccpie ? cmie osfie tmr2ie tmr1ie 000- 0000 000- 0000 9ah eedat eeprom data register 0000 0000 0000 0000 9bh eeadr eeprom address register 0000 0000 0000 0000 9ch eecon1 ? ? ? ? wrerr wren wr rd ---- x000 ---- q000 9dh eecon2 (1) eeprom control register 2 ---- ---- ---- ---- legend: x = unknown, u = unchanged, ? = unimplemented read as ? 0 ?, q = value depends upon condition. shaded cells are not used by data eeprom module. note 1: eecon2 is not a physical register.
? 2003 microchip technology inc. advance information ds41211a-page 77 PIC12F683 12.0 special features of the cpu the PIC12F683 has a host of features intended to maximize system reliability, minimize cost through elimination of external components, provide power saving features and offer code protection. these features are:  reset - power-on reset (por) - power-up timer (pwrt) - oscillator start-up timer (ost) - brown-out detect (bod)  interrupts  watchdog timer (wdt)  two-speed start-up  fail-safe clock monitor (fscm)  oscillator selection  sleep  code protection  id locations  in-circuit serial programming the PIC12F683 has two timers that offer necessary delays on power-up. one is the oscillator start-up timer (ost), intended to keep the chip in reset until the crystal oscillator is stable. the other is the power- up timer (pwrt), which provides a fixed delay of 64 ms (nominal) on power-up only, designed to keep the part in reset while the power supply stabilizes. there is also circuitry to reset the device if a brown-out occurs, which can use the power-up timer to provide at least a 64 ms reset. with these three functions on- chip, most applications need no external reset circuitry. the sleep mode is designed to offer a very low-current power-down mode. the user can wake-up from sleep through:  external reset  watchdog timer wake-up  an interrupt several oscillator options are also made available to allow the part to fit the application. the intosc option saves system cost while the lp crystal option saves power. a set of configuration bits are used to select various options (see register 12-1).
PIC12F683 ds41211a-page 78 advance information ? 2003 microchip technology inc. 12.1 configuration bits the configuration bits can be programmed (read as ? 0 ?), or left unprogrammed (read as ? 1 ?) to select various device configurations, as shown in register 12-1. these bits are mapped in program memory location 2007h. register 12-1: config ? co nfiguration word (address: 2007h) note: address 2007h is beyond the user program memory space. it belongs to the special configuration memory space (2000h - 3fffh), which can be accessed only during programming. see PIC12F683 program- ming specification for more information. ? ? fcmen ieso boden1 boden0 cpd cp mclre pwrte wdte fosc2 f0sc1 f0sc0 bit 13 bit 0 bit 13-12 unimplemented : read as ? 1 ? bit 11 fcmen: fail clock monitor enabled bit 1 = fail-safe clock monitor is enabled 0 = fail-safe clock monitor is disabled bit 10 ieso: internal external switch over bit 1 = internal external switch over mode is enabled 0 = internal external switch over mode is disabled bit 9-8 boden1:boden0 : brown-out detect selection bits (1) 11 = bod enabled 10 = bod enabled during operation and disabled in sleep 01 = bod controlled by sboden bit (pcon<4>) 00 = bod disabled bit 7 cpd : data code protection bit (2) 1 = data memory code protection is disabled 0 = data memory code protection is enabled bit 6 cp : code protection bit (3) 1 = program memory code protection is disabled 0 = program memory code protection is enabled bit 5 mclre : gp3/mclr pin function select bit (4) 1 = gp3/mclr pin function is mclr 0 = gp3/mclr pin function is digital input, mclr internally tied to v dd bit 4 pwrte : power-up timer enable bit 1 = pwrt disabled 0 = pwrt enabled bit 3 wdte : watchdog timer enable bit 1 = wdt enabled 0 = wdt disabled and can be enabled by swdten bit (wdtcon<0>) bit 2-0 fosc2:fosc0 : oscillator selection bits 111 = rc oscillator: clkout function on ra4/osc2/clkout pin, rc on ra5/osc1/clkin 110 = rc oscillator: i/o function on ra4/osc2/clkout pin, rc on ra5/osc1/clkin 101 = intosc oscillator: clkout function on ra4/os c2/clkout pin, i/o function on ra5/osc1/clkin 100 = intosc oscillator: i/o function on ra4/osc2 /clkout pin, i/o function on ra5/osc1/clkin 011 = ec: i/o function on ra4/osc2/clkout pin, clkin on ra5/osc1/clkin 010 = hs oscillator: high-speed crystal/resonator on ra4/osc2/clkout and ra5/osc1/clkin 001 = xt oscillator: crystal/resonator on ra4/osc2/clkout and ra5/osc1/clkin 000 = lp oscillator: low-power crystal on ra4/osc2/clkout and ra5/osc1/clkin note 1: enabling brown-out detect does not automatically enable power-up timer. 2: the entire data eeprom will be erased when the code protection is turned off. 3: the entire program memory will be erased when the code protection is turned off. 4: when mclr is asserted in intosc or rc mode, the internal clock oscillator is disabled.
? 2003 microchip technology inc. advance information ds41211a-page 79 PIC12F683 12.2 calibration bits the brown-out detect (bod), power-on reset (por) and 8 mhz internal oscillator (intosc) are factory calibrated. these calibration values are stored in the calibration word, as shown in register 12-2 and are mapped in program memory location 2008h. the calibration word is not erased when the device is erased when using the procedure described in the PIC12F683 programming specification. therefore, it is not necessary to store and reprogram these values when the device is erased. register 12-2: calib ? calibration word (address: 2008h) note: address 2008h is beyond the user program memory space. it belongs to the special configuration memory space (2000h - 3fffh), which can be accessed only during programming. see PIC12F683 program- ming specification for more information. fcal6 fcal5 fcal4 fcal3 fcal2 fcal1 fcal0 por1 por0 bod2 bod1 bod0 bit 13 bit 0 bit 13 unimplemented bit 12-6 fcal<6:0>: internal oscillator calibration bits 0111111 = maximum frequency . . 0000001 0000000 = center frequency 1111111 . . 1000000 = minimum frequency bit 5 unimplemented bit 4-3 por<1:0>: por calibration bits 00 = lowest por voltage 11 = highest por voltage bit 2-0 bod<2:0>: bod calibration bits 000 = reserved 001 = lowest bod voltage 111 = highest bod voltage note 1: this location does not participate in bulk erase operations if the PIC12F683 programming specification procedure is used. 2: calibration bits are reserved for factory calibration. these values can and will change across the entire range, therefore, specific values and available adjustment range can not be specified.
PIC12F683 ds41211a-page 80 advance information ? 2003 microchip technology inc. 12.3 reset the PIC12F683 differentiates between various kinds of reset: a) power-on reset (por) b) wdt reset during normal operation c) wdt reset during sleep d) mclr reset during normal operation e) mclr reset during sleep f) brown-out detect (bod) some registers are not affected in any reset condition; their status is unknown on por and unchanged in any other reset. most other registers are reset to a ?reset state? on:  power-on reset mclr reset mclr reset during sleep wdt reset  brown-out detect (bod) they are not affected by a wdt wake-up, since this is viewed as the resumption of normal operation. to and pd bits are set or cleared differently in different reset situations as indicated in table 12-2. these bits are used in software to determine the nature of the reset. see table 12-4 for a full description of reset states of all registers. a simplified block diagram of the on-chip reset circuit is shown in figure 12-1. the mclr reset path has a noise filter to detect and ignore small pulses. see table 15-4 in electrical specifications section for pulse width specification. figure 12-1: simplified block diagram of on-chip reset circuit s rq external reset mclr /v pp pin v dd osc1/ wdt module v dd rise detect ost/pwrt intrc (1) wdt time-out power-on reset ost 10-bit ripple counter pwrt chip_reset 11-bit ripple counter reset enable ost enable pwrt sleep brown-out (2) detect borsen boren clki pin note 1: this is the 32 khz intrc oscillator. see section 3.0 ?oscillator configurations? for more information. 2: refer to configuration word register.
? 2003 microchip technology inc. advance information ds41211a-page 81 PIC12F683 12.3.1 mclr PIC12F683 has a noise filter in the mclr reset path. the filter will detect and ignore small pulses. it should be noted that a wdt reset does not drive mclr pin low. the behavior of the esd protection on the mclr pin has been altered from early devices of this family. voltages applied to the pin that exceed its specification can result in both mclr resets and excessive current beyond the device specification during the esd event. for this reason, microchip recommends that the mclr pin no longer be tied directly to v dd . the use of an rc network, as shown in figure 12-2, is suggested. an internal mclr option is enabled by clearing the mclre bit in the configuration word. when cleared, mclr is internally tied to v dd and an internal weak pull-up is enabled for the mclr pin. in-circuit serial programming is not affect by selecting the internal mclr option. figure 12-2: recommended mclr circuit 12.3.2 power-on reset (por) the on-chip por circuit holds the chip in reset until v dd has reached a high enough level for proper operation. to take advantage of the por, simply tie the mclr pin through a resistor to v dd . this will eliminate external rc components usually needed to create power-on reset. a maximum rise time for v dd is required. see section 15.0 ?electrical specifica- tions? for details. if the bod is enabled, the maximum rise time specification does not apply. the bod circuitry will keep the device in reset until v dd reaches v bod (see section 12.3.5 ?brown-out detect (bod)? ). when the device starts normal operation (exits the reset condition), device operating parameters (i.e., voltage, frequency, temperature, etc.) must be met to ensure operation. if these conditions are not met, the device must be held in reset until the operating conditions are met. for additional information, refer to application note an607 ?power-up trouble shooting? (ds00607). 12.3.3 power-up timer (pwrt) the power-up timer provides a fixed 64 ms (nominal) time-out on power-up only, from por or brown-out detect. the power-up timer operates from the 31 khz intrc oscillator. for more information on the internal oscillator block, see section 3.5 ?internal oscillator block? . the chip is kept in reset as long as pwrt is active. the pwrt delay allows additional time for the v dd to rise to an acceptable level. a configuration bit, pwrte can disable (if set) or enable (if cleared or programmed) the power-up timer. the power-up timer should be enabled when brown-out detect is enabled, although it is not required. the power-up time delay will vary from chip-to-chip and due to: v dd variation  temperature variation  process variation see dc parameters for details ( section 15.0 ?electri- cal specifications? ). 12.3.4 oscillator start-up timer (ost) the oscillator start-up timer (ost) provides a 1024 oscillator cycle (from osc1 input) delay after the pwrt delay is over. this ensures that the crystal oscillator or resonator has started and stabilized. the ost time-out is invoked only for xt, lp and hs modes and only on power-on reset or wake-up from sleep. note: the por circuit does not produce an internal reset when v dd declines. to re- enable the por, v dd must reach vss for a minimum of 100 s. v dd PIC12F683 mclr r1 1k  ( or greater ) c1 0.1 f (optional, not critical)
PIC12F683 ds41211a-page 82 advance information ? 2003 microchip technology inc. 12.3.5 brown-out detect (bod) the boden0 and boden1 bits in the configuration word selects one of four bod modes. two modes have been added to allow software or hardware control of the bod enable. when boden<1:0> = 01 , the sboden bit (pcon<4>) enables/disables the bod allowing it to be controlled in software. by selecting boden<1:0>, the bod is automatically disabled in sleep to conserve power and enabled on wake-up. in this mode, the sboden bit is disabled. see register 12-1 for the configuration word definition. if v dd falls below v bod for greater than parameter (t bod ), see section 15.0 ?electrical specifica- tions? , the brown-out situation will reset the device. this will occur regardless of v dd slew-rate. a reset is not guaranteed to occur if v dd falls below v bod for less than parameter (t bod ). on any reset (power-on, brown-out detect, watchdog, etc.), the chip will remain in reset until v dd rises above bv dd (see figure 12-3). the power-up timer will now be invoked, if enabled, and will keep the chip in reset an additional 64 ms. if v dd drops below bv dd while the power-up timer is running, the chip will go back into a brown-out detect and the power-up timer will be re-initialized. once v dd rises above bv dd , the power-up timer will execute a 64 ms reset. 12.3.6 bod calibration the PIC12F683 stores the bod calibration values in fuses located in the calibration word (2008h). the calibration word is not erased when using the specified bulk erase sequence in the PIC12F683 programming specification and thus, does not require reprogramming. figure 12-3: brown-out situations note: a brown-out detect does not enable the power-up timer if the pwrte bit in the configuration word is set. note: address 2008h is beyond the user program memory space. it belongs to the special configuration memory space (2000h - 3fffh), which can be accessed only during programming. see PIC12F683 program- ming specification for more information. 64 ms (1) v bod v dd internal reset v bod v dd internal reset 64 ms (1) <64 ms 64 ms (1) v bod v dd internal reset note 1: 64 ms delay only if pwrte bit is programmed to ? 0 ?.
? 2003 microchip technology inc. advance information ds41211a-page 83 PIC12F683 12.3.7 time-out sequence on power-up, the time-out sequence is as follows: first, pwrt time-out is invoked after por has expired. then, ost is activated. the total time-out will vary based on oscillator configuration and pwrte bit status. for example, in ec mode with pwrte bit erased (pwrt disabled), there will be no time-out at all. figure 12-4, figure 12-5 and figure 12-6 depict time-out sequences. the device can execute code from the intosc while ost is active by enabling two-speed start-up or fail-safe monitor (see section 12.6.3.1 ?two-speed start-up sequence? and section 12.6.4.1 ?fail-safe mode? ). since the time-outs occur from the por pulse, if mclr is kept low long enough, the time-outs will expire. then bringing mclr high will begin execution immediately (see figure 12-5). this is useful for testing purposes or to synchronize more than one PIC12F683 device operating in parallel. table 12-6 shows the reset conditions for some special registers, while table 12-4 shows the reset conditions for all the registers. 12.3.8 power control (pcon) status register the power control/status register, pcon (address 8eh) has two status bits to indicate what type of reset that last occurred. bit0 is bod (brown-out). bod is unknown on power- on reset. it must then be set by the user and checked on subsequent resets to see if bod = 0 , indicating that a brown-out has occurred. the bod status bit is a don?t care and is not necessarily predictable if the brown-out circuit is disabled (boden<1:0> = 00 in the configuration word). bit1 is por (power-on reset). it is a ? 0 ? on power-on reset and unaffected otherwise. the user must write a ? 1 ? to this bit following a power-on reset. on a subsequent reset, if por is ? 0 ?, it will indicate that a power-on reset has occurred (i.e., v dd may have gone too low). for more information, see section 4.2.3 ?ultra low- power wake-up? and section 12.3.5 ?brown-out detect (bod)? . table 12-1: time-out in various situations table 12-2: status/pcon bits and their significance table 12-3: summary of registers associated with brown-out oscillator configuration power-up brown-out detect wake-up from sleep pwrte = 0 pwrte = 1 pwrte = 0 pwrte = 1 xt, hs, lp t pwrt + 1024t osc 1024t osc t pwrt + 1024t osc 1024t osc 1024t osc rc, ec, intosc t pwrt ?t pwrt ?? por bod to pd 0u11 power-on reset 1011 brown-out detect uu0u wdt reset uu00 wdt wake-up uuuu mclr reset during normal operation uu10 mclr reset during sleep legend: u = unchanged, x = unknown address name bit 7 bit 6 bit 5 bit 4 bit 3 bit 2 bit 1 bit 0 value on por, bod value on all other resets (1) 03h status irp rp1 rpo to pd z dc c 0001 1xxx 000q quuu 8eh pcon ? ? ulpwue sboden ? ?por bod --01 --qq --0u --uu legend: u = unchanged, x = unknown, ? = unimplemented bit, reads as ? 0 ?, q = value depends on condition. shaded cells are not used by bod. note 1: other (non power-up) resets include mclr reset and watchdog timer reset during normal operation.
PIC12F683 ds41211a-page 84 advance information ? 2003 microchip technology inc. figure 12-4: time-out sequence on power-up (mclr not tied to v dd ): case 1 figure 12-5: time-out sequence on power-up (mclr not tied to v dd ): case 2 figure 12-6: time-out sequence on power-up (mclr tied to v dd ) t pwrt t ost v dd mclr internal por pwrt time-out ost time-out internal reset v dd mclr internal por pwrt time-out ost time-out internal reset t pwrt t ost t pwrt t ost v dd mclr internal por pwrt time-out ost time-out internal reset
? 2003 microchip technology inc. advance information ds41211a-page 85 PIC12F683 table 12-4: initialization condition for registers register address power-on reset mclr reset  wdt reset  brown-out detect (1)  wake-up from sleep through interrupt  wake-up from sleep through wdt time-out w? xxxx xxxx uuuu uuuu uuuu uuuu indf 00h/80h xxxx xxxx xxxx xxxx uuuu uuuu tmr0 01h xxxx xxxx uuuu uuuu uuuu uuuu pcl 02h/82h 0000 0000 0000 0000 pc + 1 (3) status 03h/83h 0001 1xxx 000q quuu (4) uuuq quuu (4) fsr 04h/84h xxxx xxxx uuuu uuuu uuuu uuuu gpio 05h --xx xxxx --00 0000 --uu uuuu pclath 0ah/8ah ---0 0000 ---0 0000 ---u uuuu intcon 0bh/8bh 0000 0000 0000 0000 uuuu uuuu (2) pir1 0ch 000- 0000 000- 0000 uuu- uuuu (2) tmr1l 0eh xxxx xxxx uuuu uuuu uuuu uuuu tmr1h 0fh xxxx xxxx uuuu uuuu uuuu uuuu t1con 10h 0000 0000 uuuu uuuu -uuu uuuu tmr2 11h 0000 0000 0000 0000 uuuu uuuu t2con 12h -000 0000 -000 0000 -uuu uuuu ccpr1l 13h xxxx xxxx uuuu uuuu uuuu uuuu ccpr1h 14h xxxx xxxx uuuu uuuu uuuu uuuu ccp1con 15h --00 0000 --00 0000 --uu uuuu wdtcon 18h ---0 1000 ---0 1000 ---u uuuu cmcon0 19h -0-0 0000 -0-0 0000 -u-u uuuu cmcon1 20h ---- --10 ---- --10 ---- --uu adresh 1eh xxxx xxxx uuuu uuuu uuuu uuuu adcon0 1fh 00-0 0000 00-0 0000 uu-u uuuu option_reg 81h 1111 1111 1111 1111 uuuu uuuu trisio 85h --11 1111 --11 1111 --uu uuuu pie1 8ch 000- 0000 000- 0000 uuu- uuuu pcon 8eh --01 --0x --0u --uu (1,5) --uu --uu legend: u = unchanged, x = unknown, ? = unimplemented bit, reads as ? 0 ?, q = value depends on condition. note 1: if v dd goes too low, power-on reset will be activated and registers will be affected differently. 2: one or more bits in intcon and/or pir1 will be affected (to cause wake-up). 3: when the wake-up is due to an interrupt and the gie bit is set, the pc is loaded with the interrupt vector (0004h). 4: see table 12-6 for reset value for specific condition. 5: if reset was due to brown-out, then bit 0 = 0 . all other resets will cause bit 0 = u .
PIC12F683 ds41211a-page 86 advance information ? 2003 microchip technology inc. table 12-5: initialization condition for registers (continued) table 12-6: initialization condition for special registers register address power-on reset mclr reset  wdt reset  brown-out detect (1)  wake-up from sleep through interrupt  wake-up from sleep through wdt time-out osccon 8fh -110 x000 -110 x000 -uuu uuuu osctune 90h ---0 0000 ---u uuuu ---u uuuu pir2 92h 1111 1111 1111 1111 1111 1111 wpu 95h --11 -111 --11 -111 uuuu uuuu ioc 96h --00 0000 --00 0000 --uu uuuu vrcon 99h 0-0- 0000 0-0- 0000 u-u- uuuu eedat 9ah 0000 0000 0000 0000 uuuu uuuu eeadr 9bh 0000 0000 0000 0000 uuuu uuuu eecon1 9ch ---- x000 ---- q000 ---- uuuu eecon2 9dh ---- ---- ---- ---- ---- ---- adresl 9eh xxxx xxxx uuuu uuuu uuuu uuuu ansel 9fh -000 1111 -000 1111 -uuu 1111 legend: u = unchanged, x = unknown, ? = unimplemented bit, reads as ? 0 ?, q = value depends on condition. note 1: if v dd goes too low, power-on reset will be activated and registers will be affected differently. 2: one or more bits in intcon and/or pir1 will be affected (to cause wake-up). 3: when the wake-up is due to an interrupt and the gie bit is set, the pc is loaded with the interrupt vector (0004h). 4: see table 12-6 for reset value for specific condition. 5: if reset was due to brown-out, then bit 0 = 0 . all other resets will cause bit 0 = u . condition program counter status register pcon register power-on reset 000h 0001 1xxx --01 --0x mclr reset during normal operation 000h 000u uuuu --0u --uu mclr reset during sleep 000h 0001 0uuu --0u --uu wdt reset 000h 0000 uuuu --0u --uu wdt wake-up pc + 1 uuu0 0uuu --uu --uu brown-out detect 000h 0001 1uuu --01 --10 interrupt wake-up from sleep pc + 1 (1) uuu1 0uuu --uu --uu legend: u = unchanged, x = unknown, ? = unimplemented bit, reads as ? 0 ?. note 1: when the wake-up is due to an interrupt and global enable bit gie is set, the pc is loaded with the interrupt vector (0004h) after execution of pc+1.
? 2003 microchip technology inc. advance information ds41211a-page 87 PIC12F683 12.4 interrupts the PIC12F683 has 10 sources of interrupt:  external interrupt gp2/int  tmr0 overflow interrupt  gpio change interrupts  comparator interrupt  a/d interrupt  timer 1 overflow interrupt  timer 2 match interrupt  eeprom data write interrupt  fail-safe clock monitor interrupt  ccp interrupt the interrupt control register (intcon) and periph- eral interrupt register (pir1) record individual interrupt requests in flag bits. the intcon register also has individual and global interrupt enable bits. a global interrupt enable bit, gie (intcon<7>) enables (if set) all unmasked interrupts, or disables (if cleared) all interrupts. individual interrupts can be disabled through their corresponding enable bits in intcon register and pie1 register. gie is cleared on reset. the return from interrupt instruction, retfie , exits interrupt routine, as well as sets the gie bit, which re-enables unmasked interrupts. the following interrupt flags are contained in the intcon register:  int pin interrupt  gpio change interrupt  tmr0 overflow interrupt the peripheral interrupt flags are contained in the special register pir1. the corresponding interrupt enable bit is contained in special register, pie1. the following interrupt flags are contained in the pir1 register:  eeprom data write interrupt  a/d interrupt  comparator interrupt  timer1 overflow interrupt  timer 2-match interrupt  fail-safe clock monitor interrupt  ccp interrupt when an interrupt is serviced:  the gie is cleared to disable any further interrupt.  the return address is pushed onto the stack.  the pc is loaded with 0004h. for external interrupt events, such as the int pin or gpio change interrupt, the interrupt latency will be three or four instruction cycles. the exact latency depends upon when the interrupt event occurs (see figure 12-8). the latency is the same for one or two- cycle instructions. once in the interrupt service routine, the source(s) of the interrupt can be determined by polling the interrupt flag bits. the interrupt flag bit(s) must be cleared in software before re-enabling interrupts to avoid multiple interrupt requests. for additional information on timer 1, timer 2, comparator, a/d, data eeprom, ccp modules, refer to the respective peripheral section. see section 12.6.4 ?fail-safe clock monitor? for more information. note 1: individual interrupt flag bits are set, regardless of the status of their corresponding mask bit or the gie bit. 2: when an instruction that clears the gie bit is executed, any interrupts that were pending for execution in the next cycle are ignored. the interrupts which were ignored are still pending to be serviced when the gie bit is set again.
PIC12F683 ds41211a-page 88 advance information ? 2003 microchip technology inc. figure 12-7: interrupt logic tmr1if tmr1ie cmif cmie t0if t0ie intf inte gpif gpie gie peie wake-up (if in sleep mode) interrupt to cpu eeie eeif adif adie ioc-gp0 ioc0 ioc-gp1 ioc1 ioc-gp2 ioc2 ioc-gp3 ioc3 ioc-gp4 ioc4 ioc-gp5 ioc5 tmr2if tmr2ie ccp1if ccp1ie osfif osfie
? 2003 microchip technology inc. advance information ds41211a-page 89 PIC12F683 12.4.1 gp2/int interrupt external interrupt on gp2/int pin is edge-triggered; either rising if intedg bit (option<6>) is set, or falling, if intedg bit is clear. when a valid edge appears on the gp2/int pin, the intf bit (intcon<1>) is set. this interrupt can be disabled by clearing the inte control bit (intcon<4>). the intf bit must be cleared in software in the interrupt service routine before re-enabling this interrupt. the gp2/int interrupt can wake-up the processor from sleep if the inte bit was set prior to going into sleep. the status of the gie bit decides whether or not the processor branches to the interrupt vector following wake-up (0004h). see section 12.7 ?power-down mode (sleep)? for details on sleep and figure 12-13 for timing of wake-up from sleep through gp2/int interrupt. 12.4.2 tmr0 interrupt an overflow (ffh  00h) in the tmr0 register will set the t0if (intcon<2>) bit. the interrupt can be enabled/disabled by setting/clearing t0ie (intcon<5>) bit. see section 5.0 ?timer0 module? for operation of the timer0 module. 12.4.3 gpio interrupt an input change on gpio change sets the gpif (intcon<0>) bit. the interrupt can be enabled/ disabled by setting/clearing the gpie (intcon<3>) bit. plus, individual pins can be configured through the ioc register. figure 12-8: int pin interrupt timing note: the ansel (9fh) and cmcon0 (19h) registers must be initialized to configure an analog channel as a digital input. pins configured as analog inputs will read ? 0 ?. note: if a change on the i/o pin should occur when the read operation is being executed (start of the q2 cycle), then the gpif interrupt flag may not get set. q2 q1 q3 q4 q2 q1 q3 q4 q2 q1 q3 q4 q2 q1 q3 q4 q2 q1 q3 q4 osc1 clkout int pin intf flag (intcon<1>) gie bit (intcon<7>) instruction flow pc instruction fetched instruction executed interrupt latency pc pc+1 pc+1 0004h 0005h inst (0004h) inst (0005h) dummy cycle inst (pc) inst (pc+1) inst (pc-1) inst (0004h) dummy cycle inst (pc) ? note 1: intf flag is sampled here (every q1). 2: asynchronous interrupt latency = 3-4 t cy . synchronous latency = 3 t cy , where t cy = instruction cycle time. latency is the same whether inst (pc) is a single cycle or a 2-cycle instruction. 3: clkout is available only in intosc and rc oscillator modes. 4: for minimum width of int pulse, refer to ac specs. 5: intf is enabled to be set any time during the q4-q1 cycles. (1) (2) (3) (4) (5) (1)
PIC12F683 ds41211a-page 90 advance information ? 2003 microchip technology inc. table 12-7: summary of interrupt registers 12.5 context saving during interrupts during an interrupt, only the return pc value is saved on the stack. typically, users may wish to save key registers during an interrupt (e.g., w register and status register). this must be implemented in software. since the lower 16 bytes of all banks are common in the PIC12F683 (see figure 2-2), temporary holding registers w_temp, status_temp, and pclath_temp should be placed in here. these 16 locations don?t require banking and there- fore, make it easier for context save and restore. the same code shown in example 12-1 can be used.  stores the w register  stores the status register  executes the isr code  restores the status (and bank select bit register)  restores the w register example 12-1: saving status and w registers in ram addressnamebit 7bit 6bit 5bit 4bit 3bit 2 bit 1bit 0 value on por, bod value on all other resets 0bh, 8bh intcon gie peie t0ie inte gpie t0if intf gpif 0000 0000 0000 0000 0ch pir1 eeif adif ccp1if ? cmif osfif tmr2if tmr1if 000- 0000 000- 0000 8ch pie1 eeie adie ccp1ie ? cmie osfie tmr2ie tmr1ie 000- 0000 000- 0000 legend: x = unknown, u = unchanged, ? = unimplemented read as ? 0 ?, q = value depends upon condition. shaded cells are not used by the interrupt module. movwf w_temp ;copy w to temp register swapf status,w ;swap status to be saved into w clrf status ;bank 0, regardless of current bank, clears irp,rp1,rp0 movwf status_temp ;save status to bank zero status_temp register : :(isr) ;insert user code here : swapf status_temp,w ;swap status_temp register into w ;(sets bank to original state) movwf status ;move w into status register swapf w_temp,f ;swap w_temp swapf w_temp,w ;swap w_temp into w
? 2003 microchip technology inc. advance information ds41211a-page 91 PIC12F683 12.6 watchdog timer (wdt) for PIC12F683, the wdt has been modified from previous pic16 devices. the new wdt is code and functionally backward compatible with previous pic16 wdt modules, and allows the user to have a scaler value for the wdt and tmr0 at the same time. in addition, the wdt time-out value can be extended to 268 seconds, using the prescaler with the postscaler when psa is set to ? 1 ?. 12.6.1 wdt oscillator the wdt derives its time base from the 31 khz intrc; therefore, the accuracy of the 31 khz will be the same accuracy for the wdt time-out period. the lts (osccon<1>) status bit does not reflect that the intrc is enabled. the value of wdtcon is ? ---0 1000 ? on all resets. this gives a nominal time base of 18 ms, which is compatible with the time base generated with previous pic16 microcontroller versions. a new prescaler has been added to the path between the intrc and the multiplexors used to select the path for the wdt. this prescaler is 16 bits and can be programmed to divide the intrc by 128 to 65536, giving the time base used for the wdt a nominal range of 1 ms to 268s. 12.6.2 wdt control the wdten bit is located in configuration word and when this bit is set, the wdt runs continuously. when the wdten bit in the configuration word register is set, the swdten bit (wdtcon<0>) has no effect. if wdten is clear, then the swdten bit can be used to enable and disable the wdt. setting the bit will enable it and clearing the bit will disable it. the psa and ps<2:0> bits (option_reg) have the same function as in previous versions of the pic16 family of microcontrollers. see section 5.0 ?timer0 module? for more information. figure 12-9: watchdog timer block diagram note: when the oscillator start-up timer (ost) is invoked, the wdt is held in reset, because the wdt ripple counter is used by the ost to perform the oscillator delay count. when the ost count has expired, the wdt will begin counting (if enabled). table 12-8: prescaler/postscaler bit status conditions prescaler postscaler (psa = 1) wdten = ? 0 ? cleared cleared clrwdt command osc fail detected exit sleep + system clock = t1osc, extrc, intrc, extclk exit sleep + system clock = xt, hs, lp cleared at end of ost cleared at end of ost 31 khz psa 16-bit programmable prescaler wdt from tmr0 clock source prescaler (1) 8 ps<2:0> psa wdt time-out to tmr0 wdtps<3:0> wdten from configuration word 1 1 0 0 swdten from wdtcon intrc clock note1 : this is the shared timer 0/wdt prescaler. see section 5.4 ?prescaler? for more information.
PIC12F683 ds41211a-page 92 advance information ? 2003 microchip technology inc. register 12-3: wdtcon ? register (address: 18h) table 12-9: summary of watchdog timer registers u-0 u-0 u-0 r/w-0 r/w-1 r/w-0 r/w-0 r/w-0 ? ? ? wdtps3 wdtps2 wdtps1 wdtps0 swdten bit 7 bit 0 bit 7-5 unimplemented: read as ? 0 ? bit 4-1 wdtps<3:0>: watchdog timer period select bits bit value prescale rate 0000 = 1:32 0001 = 1:64 0010 = 1:128 0011 = 1:256 0100 = 1:512 0101 = 1:1024 0110 = 1:2048 0111 = 1:4096 1000 = 1:8192 1001 = 1:16394 1010 = 1:32768 1011 = 1:65536 1100 = reserved 1101 = reserved 1110 = reserved 1111 = reserved bit 0 swdten: software enable/disable for watchdog timer bit (1) 1 = wdt is turned on 0 = wdt is turned off legend: r = readable bit w = writable bit u = unimplemented bit, read as ?0? -n = value at por ?1? = bit is set ?0? = bit is cleared x = bit is unknown address name bit 7 bit 6 bit 5 bit 4 bit 3 bit 2 bit 1 bit 0 18h wdtcon ? ? ? wdtps3 wdtps2 wstps1 wdtps0 swdten 81h option_reg gpp u intedg t0cs t0se psa ps2 ps1 ps0 2007h (1) configuration bits cpd cp mclre pwrte wdte fosc2 f0sc1 f0sc0 legend: shaded cells are not used by the watchdog timer. note 1: see register 12-1 for operation of these bits.
? 2003 microchip technology inc. advance information ds41211a-page 93 PIC12F683 12.6.3 two-speed clock start-up mode two-speed start-up minimizes the latency between oscillator start-up and code execution that may be selected with the ieso (internal/external switch over) bit in configuration word. this mode is achieved by initially using the intosc for code execution until the primary oscillator is stable. this results in code execution with a minimum delay. see section 3.5 ?internal oscillator block? for more information. if this mode is enabled and any of the following conditions exist, the system will begin execution with the intosc oscillator.  por and after the power-up timer has expired (if pwrten = ? 0 ?),  or following a wake-up from sleep,  or a reset when running from intosc. after a reset, scs bit (osccon<0>) is always cleared. if the primary oscillator is configured to be anything other than xt, lp, or hs, then two-speed start-up is disabled, because the primary oscillator will not require any time to become stable after por, or an exit from sleep. checking the state of the osts bit will confirm whether the primary clock configuration is engaged. if the osts bit is set, the device is running from the primary clock source as defined by the f osc bits in the configuration word. if the system clock is being generated from the intosc as the secondary clock source then osts bit will be clear. this mode allows the application to wake-up from sleep, perform a few instructions using the intosc as the clock source and go back to sleep without waiting for the primary oscillator to become stable. 12.6.3.1 two-speed start-up sequence 1. wake-up from sleep, reset or por. 2. instructions begin execution by intosc at the frequency set in the ircf bits (osccon<6:4>). 3. ost enabled to count 1024 clock cycles. 4. ost timed out, wait for falling edge of intosc. 5. osts is set. 6. system clock held low until the next falling edge of new clock (lp, xt, or hs). 7. system clock is switched to primary source. the software may read the osts bit to determine when the switch over takes place so that any software timing can be adjusted. figure 12-10: two-speed start-up note: following any reset, the ircf bits are set to ?110? and the frequency selection is forced to 4 mhz. the user can modify the ircf bits to select a different internal oscil- lator frequency. note: executing a sleep instruction will abort the oscillator start-up time and will cause the osts bit (osccon<3>) to remain clear. q1 q2 q3 q4 q1 q2 q3 q4 q1 0 1 1022 1023 pc pc + 1 pc + 2 t ost t intosc osc1 osc2 program counter system clock
PIC12F683 ds41211a-page 94 advance information ? 2003 microchip technology inc. 12.6.4 fail-safe clock monitor the fail-safe clock monitor (fscm) is designed to allow the device to continue to operate in the event of an oscillator failure. the fscm can detect oscillator failure at any point after the device has exited a reset or sleep condition and the oscillator start-up timer (ost) has expired. figure 12-11: fscm block diagram the fscm function is enabled by setting the fcmen bit in configuration word. it is applicable to all oscillator options except intosc. in the event of an oscillator failure, the fscm will set the osfif bit (pir1<2>) and generate an oscillator fail interrupt if the osfie bit (pie1<2>) is set. the device will then switch the system clock to the intosc. the system will continue to come from the intosc unless the primary oscillator recovers and the fail-safe condition is exited. the frequency of the internal oscillator will depend upon the value contained in the ircf bits (osccon<6:4>). upon entering the fail-safe condition, the osts bit (osccon<3>) is automati- cally cleared to reflect that the secondary oscillator is active and the wdt is cleared. the scs bit (osccon<0>) is not updated. the intrc is enabled and the fscm sample clock is generated by dividing the intrc clock by 64. this will allow enough time between fscm sample clocks for a system clock edge to occur. the lts (osccon<1>) status bit does not reflect that the intrc is enabled. on the rising edge of the post scaled clock, the monitoring latch (cm = ? 0 ?) will be cleared. on a falling edge of the primary system clock, the monitoring latch will be set (cm = ? 1 ?). in the event that a falling edge of the post scaled clock occurs, and the monitoring latch is not set, a clock failure has been detected. 12.6.4.1 fail-safe mode the fail-safe condition is exited with either a reset, the execution of a sleep instruction or a modification of the scs bit. while in fail-safe mode, the PIC12F683 uses the secondary clock, intosc, as the system clock source. the ircf bits (osccon<6:4>) can be modified to adjust the intosc frequency with- out exiting the fail-safe condition. in this mode, the user can set the scs bit (osccon<0>) to exit the fail-safe condition and then clear the scs bit to attempt to restart the primary oscillator. if it starts, the fscm will be reenabled after the ost expires. if it fails to start, the intosc will continue to supply the system clock but the device will not reenter the fail-safe condition. note: two-speed start-up is automatically enabled when the fail-safe option is enabled. primary intrc 64 s c q 31 khz (~32 s) 488 hz (~2 ms) clock monitor latch (cm) (edge-triggered) clock failure detected oscillator clock q note: the intosc will be enabled if the ircf (osccon<6:4>) selects a frequency greater than 31khz (ircf<2:0>  ? 000 ?).
? 2003 microchip technology inc. advance information ds41211a-page 95 PIC12F683 figure 12-12: fscm timing diagram 12.6.4.2 reset or wake-up from sleep the fscm is designed to detect oscillator failure at any point after the device has exited a reset or sleep condition and the oscillator start-up timer (ost) has expired. if the primary system clock is ec or rc mode, monitoring will begin immediately following these events. for hs, lp or xt mode, the situation is somewhat different. since the oscillator may require a start-up time considerably longer than the fscm sample clock time, a false clock failure may be detected. to prevent this, the internal oscillator block is automatically configured as the system clock and functions until the primary clock is stable (the ost has timed out). this is identical to two-speed start-up mode. once the primary clock is stable, the intrc returns to its role as the fscm source. oscfif cm output system clock output sample clock failure detected oscillator failure note: the system clock is normally at a much higher frequency than the sample clock. the relative frequencies in this example have been chosen for clarity. (q ) cm test cm test cm test note: due to the wide range of oscillator start-up times, the fail-safe circuit is not active during oscillator start-up (i.e., after exiting reset or sleep). after an appropriate amount of time, the user should check the osts bit (osccon<3>) to verify the oscillator start-up and system clock switch-over have successfully completed.
PIC12F683 ds41211a-page 96 advance information ? 2003 microchip technology inc. 12.7 power-down mode (sleep) the power-down mode is entered by executing a sleep instruction. if the watchdog timer is enabled:  wdt will be cleared but keeps running pd bit in the status register is cleared to bit is set  oscillator driver is turned off  i/o ports maintain the status they had before sleep was executed (driving high, low or hi-impedance). for lowest current consumption in this mode, all i/o pins should be either at v dd or v ss , with no external circuitry drawing current from the i/o pin and the comparator and cv ref should be disabled. i/o pins that are hi-impedance inputs should be pulled high or low externally to avoid switching currents caused by floating inputs. the t0cki input should also be at v dd or v ss for lowest current consumption. the contribu- tion from on-chip pull-ups on gpio should be considered. the mclr pin must be at a logic high level. 12.7.1 wake-up from sleep the device can wake-up from sleep through one of the following events: 1. external reset input on mclr pin 2. watchdog timer wake-up (if wdt was enabled) 3. interrupt from gp2/int pin, gpio change or a peripheral interrupt. the first event will cause a device reset. the two latter events are considered a continuation of program execution. the to and pd bits in the status register can be used to determine the cause of device reset. the pd bit, which is set on power-up, is cleared when sleep is invoked. to bit is cleared if wdt wake-up occurred. the following peripheral interrupts can wake the device from sleep: 1. tmr1 interrupt. timer1 must be operating as an asynchronous counter. 2. ccp capture mode interrupt. 3. special event trigger (timer1 in asynchronous mode using an external clock). 4. a/d conversion (when a/d clock source is rc). 5. eeprom write operation completion. 6. comparator output changes state. 7. interrupt-on-change. 8. external interrupt from int pin. other peripherals cannot generate interrupts, since during sleep, no on-chip clocks are present. when the sleep instruction is being executed, the next instruction (pc + 1) is pre-fetched. for the device to wake-up through an interrupt event, the correspond- ing interrupt enable bit must be set (enabled). wake- up is regardless of the state of the gie bit. if the gie bit is clear (disabled), the device continues execution at the instruction after the sleep instruction. if the gie bit is set (enabled), the device executes the instruction after the sleep instruction, then branches to the inter- rupt address (0004h). in cases where the execution of the instruction following sleep is not desirable, the user should have an nop after the sleep instruction. the wdt is cleared when the device wakes up from sleep, regardless of the source of wake-up. 12.7.2 wake-up using interrupts when global interrupts are disabled (gie cleared) and any interrupt source has both its interrupt enable bit and interrupt flag bit set, one of the following will occur:  if the interrupt occurs before the execution of a sleep instruction, the sleep instruction will complete as a nop . therefore, the wdt and wdt prescaler and postscaler (if enabled) will not be cleared, the to bit will not be set and the pd bit will not be cleared.  if the interrupt occurs during or after the execution of a sleep instruction, the device will immediately wake-up from sleep. the sleep instruction will be completely executed before the wake-up. therefore, the wdt and wdt prescaler and postscaler (if enabled) will be cleared, the to bit will be set and the pd bit will be cleared. even if the flag bits were checked before executing a sleep instruction, it may be possible for flag bits to become set before the sleep instruction completes. to determine whether a sleep instruction executed, test the pd bit. if the pd bit is set, the sleep instruction was executed as a nop . to ensure that the wdt is cleared, a clrwdt instruction should be executed before a sleep instruction. note: it should be noted that a reset generated by a wdt time-out does not drive mclr pin low. note: if the global interrupts are disabled (gie is cleared), but any interrupt source has both its interrupt enable bit and the correspond- ing interrupt flag bits set, the device will immediately wake-up from sleep. the sleep instruction is completely executed.
? 2003 microchip technology inc. advance information ds41211a-page 97 PIC12F683 figure 12-13: wake-up from sleep through interrupt q1 q2 q3 q4 q1 q2 q3 q4 q1 q1 q2 q3 q4 q1 q2 q3 q4 q1 q2 q3 q4 q1 q2 q3 q4 osc1 clkout (4) int pin intf flag (intcon<1>) gie bit (intcon<7>) instruction flow pc instruction fetched instruction executed pc pc+1 pc+2 inst(pc) = sleep inst(pc - 1) inst(pc + 1) sleep processor in sleep interrupt latency (3) inst(pc + 2) inst(pc + 1) inst(0004h) inst(0005h) inst(0004h) dummy cycle pc + 2 0004h 0005h dummy cycle t ost (2) pc+2 note 1: xt, hs or lp oscillator mode assumed. 2: t ost = 1024t osc (drawing not to scale). this delay does not apply to ec and rc oscillator modes. 3: gie = ? 1 ? assumed. in this case after wake-up, the processor jumps to 0004h. if gie = ? 0 ?, execution will continue in-line. 4: clkout is not available in xt, hs, lp or ec osc modes, but shown here for timing reference.
PIC12F683 ds41211a-page 98 advance information ? 2003 microchip technology inc. 12.8 code protection if the code protection bit(s) have not been programmed, the on-chip program memory can be read out using icsp for verification purposes. 12.9 id locations four memory locations (2000h-2003h) are designated as id locations where the user can store checksum or other code identification numbers. these locations are not accessible during normal execution but are readable and writable during program/verify. only the least significant 7 bits of the id locations are used. 12.10 in-circuit serial programming the PIC12F683 microcontrollers can be serially programmed while in the end application circuit. this is simply done with two lines for clock and data, and three other lines for:  power  ground  programming voltage this allows customers to manufacture boards with unprogrammed devices and then program the microcontroller just before shipping the product. this also allows the most recent firmware or a custom firmware to be programmed. the device is placed into a program/verify mode by holding the gp0 and gp1 pins low, while raising the mclr (v pp ) pin from v il to v ihh (see programming specification). gp0 becomes the programming data and gp1 becomes the programming clock. both gp0 and gp1 are schmitt trigger inputs in this mode. after reset, to place the device into program/verify mode, the program counter (pc) is at location 00h. a 6-bit command is then supplied to the device. depending on the command, 14 bits of program data are then supplied to or from the device, depending on whether the command was a load or a read. for complete details of serial programming, please refer to the PIC12F683 programming specification. a typical in-circuit serial programming connection is shown in figure 12-14. figure 12-14: typical in-circuit serial programming connection note: the entire data eeprom and flash program memory will be erased when the code protection is turned off. see PIC12F683 programming specification for more information. external connector signals to n o r m a l connections to n o rm a l connections PIC12F683 v dd v ss mclr / v pp /gp3 gp1 gp0 +5v 0v v pp clk data i/o * * * * * isolation devices (as required)
? 2003 microchip technology inc. advance information ds41211a-page 99 PIC12F683 12.11 in-circuit debugger since in-circuit debugging requires the loss of clock, data and mclr pins, mplab ? icd 2 development with an 8-pin device is not practical. a special 14-pin PIC12F683-icd device is used with mplab icd 2 to provide separate clock, data and mclr pins and frees all normally available pins to the user. this special icd device is mounted on the top of the header and its signals are routed to the mplab icd 2 connector. on the bottom of the header is an 8-pin socket that plugs into the user?s target via the 8-pin stand-off connector. when the icd pin on the PIC12F683-icd device is held low, the in-circuit debugger functionality is enabled. this function allows simple debugging functions when used with mplab icd 2. when the microcontroller has this feature enabled, some of the resources are not available for general use. table 12-10 shows which features are consumed by the background debugger: table 12-10: debugger resources for more information, see mplab icd 2 in-circuit debugger user?s guide (ds51292) available on microchip?s web site (www.microchip.com). figure 12-15: 14-pin icd pinout resource description i/o pins icdclk, icddata stack 1 level program memory address 0h must be nop 700h - 7ffh 14-pin pdip PIC12F683-icd in-circuit debug device nc icdmclr /v pp v dd gp5 gp4 gp3 icdclk icddata vss gp0 icd nc gp1 gp2 1 2 3 4 5 6 7 14 13 12 11 10 9 8
PIC12F683 ds41211a-page 100 advance information ? 2003 microchip technology inc. notes:
? 2003 microchip technology inc. advance information ds41211a-page 101 PIC12F683 13.0 instruction set summary the PIC12F683 instruction set is highly orthogonal and is comprised of three basic categories:  byte-oriented operations  bit-oriented operations  literal and control operations each pic16 instruction is a 14-bit word divided into an opcode, which specifies the instruction type and one or more operands, which further specify the operation of the instruction. the formats for each of the categories is presented in figure 13-1, while the various opcode fields are summarized in table 13-1. table 13-2 lists the instructions recognized by the mpasm tm assembler. a complete description of each instruction is also available in the picmicro ? mid- range reference manual (ds33023). for byte-oriented instructions, ? f ? represents a file register designator and ? d ? represents a destination designator. the file register designator specifies which file register is to be used by the instruction. the destination designator specifies where the result of the operation is to be placed. if ? d ? is zero, the result is placed in the w register. if ? d ? is one, the result is placed in the file register specified in the instruction. for bit-oriented instructions, ? b ? represents a bit field designator, which selects the bit affected by the operation, while ? f ? represents the address of the file in which the bit is located. for literal and control operations, ? k ? represents an 8-bit or 11-bit constant, or literal value. one instruction cycle consists of four oscillator periods; for an oscillator frequency of 4 mhz, this gives a normal instruction execution time of 1 s. all instructions are executed within a single instruction cycle, unless a conditional test is true or the program counter is changed as a result of an instruction. when this occurs, the execution takes two instruction cycles, with the second cycle executed as a nop . all instruction examples use the format ?0xhh? to represent a hexadecimal number, where ?h? signifies a hexadecimal digit. 13.1 read-modify-write operations any instruction that specifies a file register as part of the instruction performs a read-modify-write (r-m-w) operation. the register is read, the data is modified, and the result is stored according to either the instruc- tion or the destination designator ?d?. a read operation is performed on a register even if the instruction writes to that register. for example, a clrf gpio instruction will read gpio, clear all the data bits, then write the result back to gpio. this example would have the unintended result of clearing the condition that set the gpif flag. table 13-1: opcode field descriptions figure 13-1: general format for instructions note: to maintain upward compatibility with future products, do not use the option and tris instructions. field description f register file address (0x00 to 0x7f) w working register (accumulator) b bit address within an 8-bit file register k literal field, constant data or label x don't care location (= 0 or 1 ). the assembler will generate code with x = 0 . it is the recommended form of use for compatibility with all microchip software tools. d destination select; d = 0 : store result in w, d = 1: store result in file register f. default is d = 1. pc program counter to time-out bit pd power-down bit byte-oriented file register operations 13 8 7 6 0 d = 0 for destination w opcode d f (file #) d = 1 for destination f f = 7-bit file register address bit-oriented file register operations 13 10 9 7 6 0 opcode b (bit #) f (file #) b = 3-bit bit address f = 7-bit file register address literal and control operations 13 8 7 0 opcode k (literal) k = 8-bit immediate value 13 11 10 0 opcode k (literal) k = 11-bit immediate value general call and goto instructions only
PIC12F683 ds41211a-page 102 advance information ? 2003 microchip technology inc. table 13-2: PIC12F683 instruction set mnemonic, operands description cycles 14-bit opcode status affected notes msb lsb byte-oriented file register operations addwf andwf clrf clrw comf decf decfsz incf incfsz iorwf movf movwf nop rlf rrf subwf swapf xorwf f, d f, d f - f, d f, d f, d f, d f, d f, d f, d f - f, d f, d f, d f, d f, d add w and f and w with f clear f clear w complement f decrement f decrement f, skip if 0 increment f increment f, skip if 0 inclusive or w with f move f move w to f no operation rotate left f through carry rotate right f through carry subtract w from f swap nibbles in f exclusive or w with f 1 1 1 1 1 1 1 (2) 1 1 (2) 1 1 1 1 1 1 1 1 1 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 0111 0101 0001 0001 1001 0011 1011 1010 1111 0100 1000 0000 0000 1101 1100 0010 1110 0110 dfff dfff lfff 0xxx dfff dfff dfff dfff dfff dfff dfff lfff 0xx0 dfff dfff dfff dfff dfff ffff ffff ffff xxxx ffff ffff ffff ffff ffff ffff ffff ffff 0000 ffff ffff ffff ffff ffff c,dc,z z z z z z z z z c c c,dc,z z 1,2 1,2 2 1,2 1,2 1,2,3 1,2 1,2,3 1,2 1,2 1,2 1,2 1,2 1,2 1,2 bit-oriented file register operations bcf bsf btfsc btfss f, b f, b f, b f, b bit clear f bit set f bit test f, skip if clear bit test f, skip if set 1 1 1 (2) 1 (2) 01 01 01 01 00bb 01bb 10bb 11bb bfff bfff bfff bfff ffff ffff ffff ffff 1,2 1,2 3 3 literal and control operations addlw andlw call clrwdt goto iorlw movlw retfie retlw return sleep sublw xorlw k k k - k k k - k - - k k add literal and w and literal with w call subroutine clear watchdog timer go to address inclusive or literal with w move literal to w return from interrupt return with literal in w return from subroutine go into standby mode subtract w from literal exclusive or literal with w 1 1 2 1 2 1 1 2 2 2 1 1 1 11 11 10 00 10 11 11 00 11 00 00 11 11 111x 1001 0kkk 0000 1kkk 1000 00xx 0000 01xx 0000 0000 110x 1010 kkkk kkkk kkkk 0110 kkkk kkkk kkkk 0000 kkkk 0000 0110 kkkk kkkk kkkk kkkk kkkk 0100 kkkk kkkk kkkk 1001 kkkk 1000 0011 kkkk kkkk c,dc,z z to ,pd z to ,pd c,dc,z z note 1: when an i/o register is modified as a function of itself (e.g., movf gpio, 1 ), the value used will be that value present on the pins themselves. for example, if the data latch is ?1? for a pin configured as input and is driven low by an external device, the data will be written back with a ?0?. 2: if this instruction is executed on the tmr0 register (and, wher e applicable, d = 1), the prescaler will be cleared if assigned to the timer0 module. 3: if program counter (pc) is modified or a conditional test is true, the instruction requires two cycles. the second cycle is executed as a nop . note: additional information on the mid-range instruction set is available in the picmicro ? mid-range mcu family reference manual (ds33023).
? 2003 microchip technology inc. advance information ds41211a-page 103 PIC12F683 13.2 instruction descriptions addlw add literal and w syntax: [ label ] addlw k operands: 0  k  255 operation: (w) + k  (w) status affected: c, dc, z description: the contents of the w register are added to the eight-bit literal ?k? and the result is placed in the w register. addwf add w and f syntax: [ label ] addwf f,d operands: 0  f  127 d  [0,1] operation: (w) + (f)  (destination) status affected: c, dc, z description: add the contents of the w register with register ?f?. if ?d? is 0, the result is stored in the w register. if ?d? is 1, the result is stored back in register ?f?. andlw and literal with w syntax: [ label ] andlw k operands: 0  k  255 operation: (w) .and. (k)  (w) status affected: z description: the contents of w register are and?ed with the eight-bit literal ?k?. the result is placed in the w register. andwf and w with f syntax: [ label ] andwf f,d operands: 0  f  127 d  [0,1] operation: (w) .and. (f)  (destination) status affected: z description: and the w register with register ?f?. if ?d? is 0, the result is stored in the w register. if ?d? is 1, the result is stored back in register ?f?. bcf bit clear f syntax: [ label ] bcf f,b operands: 0  f  127 0  b  7 operation: 0  (f) status affected: none description: bit ?b? in register ?f? is cleared. bsf bit set f syntax: [ label ] bsf f,b operands: 0  f  127 0  b  7 operation: 1  (f) status affected: none description: bit ?b? in register ?f? is set. btfss bit test f, skip if set syntax: [ label ] btfss f,b operands: 0  f  127 0  b < 7 operation: skip if (f) = 1 status affected: none description: if bit ?b? in register ?f? is 0, the next instruction is executed. if bit ?b? is 1, then the next instruc- tion is discarded and a nop is executed instead, making this a 2-cycle instruction. btfsc bit test, skip if clear syntax: [ label ] btfsc f,b operands: 0  f  127 0  b  7 operation: skip if (f) = 0 status affected: none description: if bit ?b? in register ?f? is 1, the next instruction is executed. if bit ?b? in register ?f? is 0, the next instruction is discarded, and a nop is executed instead, making this a 2-cycle instruction.
PIC12F683 ds41211a-page 104 advance information ? 2003 microchip technology inc. call call subroutine syntax: [ label ] call k operands: 0  k  2047 operation: (pc)+ 1  tos, k  pc<10:0>, (pclath<4:3>)  pc<12:11> status affected: none description: call subroutine. first, return address (pc+1) is pushed onto the stack. the eleven-bit immedi- ate address is loaded into pc bits <10:0>. the upper bits of the pc are loaded from pclath. call is a two-cycle instruction. clrf clear f syntax: [ label ] clrf f operands: 0  f  127 operation: 00h  (f) 1  z status affected: z description: the contents of register ?f? are cleared and the z bit is set. clrw clear w syntax: [ label ] clrw operands: none operation: 00h  (w) 1  z status affected: z description: w register is cleared. zero bit (z) is set. clrwdt clear watchdog timer syntax: [ label ] clrwdt operands: none operation: 00h  wdt 0  wdt prescaler, 1  to 1  pd status affected: to , pd description: clrwdt instruction resets the watchdog timer. it also resets the prescaler of the wdt. status bits to and pd are set. comf complement f syntax: [ label ] comf f,d operands: 0  f  127 d  [0,1] operation: (f )  (destination) status affected: z description: the contents of register ?f? are complemented. if ?d? is 0, the result is stored in w. if ?d? is 1, the result is stored back in register ?f?. decf decrement f syntax: [ label ] decf f,d operands: 0  f  127 d  [0,1] operation: (f) - 1  (destination) status affected: z description: decrement register ?f?. if ?d? is 0, the result is stored in the w register. if ?d? is 1, the result is stored back in register ?f?. decfsz decrement f, skip if 0 syntax: [ label ] decfsz f,d operands: 0  f  127 d  [0,1] operation: (f) - 1  (destination); skip if result = 0 status affected: none description: the contents of register ?f? are decremented. if ?d? is 0, the result is placed in the w register. if ?d? is 1, the result is placed back in register ?f?. if the result is 1, the next instruc- tion is executed. if the result is 0, then a nop is executed instead, making it a 2-cycle instruction.
? 2003 microchip technology inc. advance information ds41211a-page 105 PIC12F683 goto unconditional branch syntax: [ label ] goto k operands: 0  k  2047 operation: k  pc<10:0> pclath<4:3>  pc<12:11> status affected: none description: goto is an unconditional branch. the eleven-bit immediate value is loaded into pc bits <10:0>. the upper bits of pc are loaded from pclath<4:3>. goto is a two- cycle instruction. incf increment f syntax: [ label ] incf f,d operands: 0  f  127 d  [0,1] operation: (f) + 1  (destination) status affected: z description: the contents of register ?f? are incremented. if ?d? is 0, the result is placed in the w register. if ?d? is 1, the result is placed back in register ?f?. incfsz increment f, skip if 0 syntax: [ label ] incfsz f,d operands: 0  f  127 d  [0,1] operation: (f) + 1  (destination), skip if result = 0 status affected: none description: the contents of register ?f? are incremented. if ?d? is 0, the result is placed in the w register. if ?d? is 1, the result is placed back in register ?f?. if the result is 1, the next instruc- tion is executed. if the result is 0, a nop is executed instead, making it a 2-cycle instruction. movf move f syntax: [ label ] movf f,d operands: 0  f  127 d  [0,1] operation: (f)  (dest) status affected: z encoding: 00 1000 dfff ffff description: the contents of register f is moved to a destination dependent upon the status of d. if d = 0, destination is w register. if d = 1, the destination is file register f itself. d = 1 is useful to test a file register since status flag z is affected. words: 1 cycles: 1 example movf fsr, 0 after instruction w = value in fsr register z= 1 movwf move w to f syntax: [ label ] movwf f operands: 0  f  127 operation: (w)  (f) status affected: none encoding: 00 0000 1fff ffff description: move data from w register to register ?f?. words: 1 cycles: 1 example movwf option before instruction option = 0xff w = 0x4f after instruction option = 0x4f w = 0x4f
PIC12F683 ds41211a-page 106 advance information ? 2003 microchip technology inc. iorlw inclusive or literal with w syntax: [ label ] iorlw k operands: 0  k  255 operation: (w) .or. k  (w) status affected: z description: the contents of the w register are or?ed with the eight-bit literal ?k?. the result is placed in the w register. iorwf inclusive or w with f syntax: [ label ] iorwf f,d operands: 0  f  127 d  [0,1] operation: (w) .or. (f)  (destination) status affected: z description: inclusive or the w register with register ?f?. if ?d? is 0, the result is placed in the w register. if ?d? is 1, the result is placed back in register ?f?. movlw move literal to w syntax: [ label ] movlw k operands: 0  k  255 operation: k  (w) status affected: none encoding: 11 00xx kkkk kkkk description: the eight bit literal ?k? is loaded into w register. the don?t cares will assemble as ?0?s . words: 1 cycles: 1 example movlw 0x5a after instruction w = 0x5a nop no operation syntax: [ label ] nop operands: none operation: no operation status affected: none encoding: 00 0000 0xx0 0000 description: no operation. words: 1 cycles: 1 example nop retfie return from interrupt syntax: [ label ] retfie operands: none operation: tos  pc, 1  gie status affected: none encoding: 00 0000 0000 1001 description: return from interrupt. stack is poped and top of stack (tos) is loaded in the pc. interrupts are enabled by setting global interrupt enable bit, gie (intcon<7>). this is a two-cycle instruction. words: 1 cycles: 2 example retfie after interrupt pc = tos gie = 1
? 2003 microchip technology inc. advance information ds41211a-page 107 PIC12F683 retlw return with literal in w syntax: [ label ] retlw k operands: 0  k  255 operation: k  (w); tos  pc status affected: none encoding: 11 01xx kkkk kkkk description: the w register is loaded with the eight bit literal ?k?. the program counter is loaded from the top of the stack (the return address). this is a two-cycle instruction. words: 1 cycles: 2 example table call table;w contains table ;offset value  ;w now has table value   addwf pc ;w = offset retlw k1 ;begin table retlw k2 ;    retlw kn ; end of table before instruction w = 0x07 after instruction w = value of k8 return return from subroutine syntax: [ label ] return operands: none operation: tos  pc status affected: none description: return from subroutine. the stack is poped and the top of the stack (tos) is loaded into the program counter. this is a two-cycle instruction. rlf rotate left f through carry syntax: [ label ] rlf f,d operands: 0  f  127 d  [0,1] operation: see description below status affected: c encoding: 00 1101 dfff ffff description: the contents of register ?f? are rotated one bit to the left through the carry flag. if ?d? is 0, the result is placed in the w register. if ?d? is 1, the result is stored back in register ?f?. words: 1 cycles: 1 example rlf reg1,0 before instruction reg1 = 1110 0110 c=0 after instruction reg1 = 1110 0110 w = 1100 1100 c=1 rrf rotate right f through carry syntax: [ label ] rrf f,d operands: 0  f  127 d  [0,1] operation: see description below status affected: c description: the contents of register 'f' are rotated one bit to the right through the carry flag. if ?d? is 0, the result is placed in the w register. if ?d? is 1, the result is placed back in register ?f?. register f c register f c
PIC12F683 ds41211a-page 108 advance information ? 2003 microchip technology inc. sleep syntax: [ label ] sleep operands: none operation: 00h  wdt, 0  wdt prescaler, 1  to , 0  pd status affected: to , pd description: the power-down status bit, pd is cleared. time-out status bit, to is set. watchdog timer and its prescaler are cleared. the processor is put into sleep mode with the oscillator stopped. sublw subtract w from literal syntax: [ label ] sublw k operands: 0  k  255 operation: k - (w)  ( w) status affected: c, dc, z description: the w register is subtracted (2?s complement method) from the eight-bit literal ?k?. the result is placed in the w register. subwf subtract w from f syntax: [ label ] subwf f,d operands: 0  f  127 d  [0,1] operation: (f) - (w)  ( destination) status affected: c, dc, z description: subtract (2?s complement method) w register from register ?f?. if ?d? is 0, the result is stored in the w register. if ?d? is 1, the result is stored back in register ?f?. swapf swap nibbles in f syntax: [ label ] swapf f,d operands: 0  f  127 d  [0,1] operation: (f<3:0>)  (destination<7:4>), (f<7:4>)  (destination<3:0>) status affected: none description: the upper and lower nibbles of register ?f? are exchanged. if ?d? is 0, the result is placed in the w register. if ?d? is 1, the result is placed in register ?f?. xorlw exclusive or literal with w syntax: [ label ] xorlw k operands: 0  k  255 operation: (w) .xor. k  ( w) status affected: z description: the contents of the w register are xor?ed with the eight-bit literal ?k?. the result is placed in the w register. xorwf exclusive or w with f syntax: [ label ] xorwf f,d operands: 0  f  127 d  [0,1] operation: (w) .xor. (f)  ( destination) status affected: z description: exclusive or the contents of the w register with register ?f?. if ?d? is 0, the result is stored in the w register. if ?d? is 1, the result is stored back in register ?f?.
? 2003 microchip technology inc. advance information ds41211a-page 109 PIC12F683 14.0 development support the picmicro ? microcontrollers are supported with a full range of hardware and software development tools:  integrated development environment - mplab ? ide software  assemblers/compilers/linkers - mpasm tm assembler - mplab c17 and mplab c18 c compilers -mplink tm object linker/ mplib tm object librarian - mplab c30 c compiler - mplab asm30 assembler/linker/library  simulators - mplab sim software simulator - mplab dspic30 software simulator emulators - mplab ice 2000 in-circuit emulator - mplab ice 4000 in-circuit emulator  in-circuit debugger - mplab icd 2  device programmers -pro mate ? ii universal device programmer - picstart ? plus development programmer  low cost demonstration boards - picdem tm 1 demonstration board - picdem.net tm demonstration board - picdem 2 plus demonstration board - picdem 3 demonstration board - picdem 4 demonstration board - picdem 17 demonstration board - picdem 18r demonstration board - picdem lin demonstration board - picdem usb demonstration board  evaluation kits -k ee l oq ? - picdem msc -microid ? -can - powersmart ? -analog 14.1 mplab integrated development environment software the mplab ide software brings an ease of software development previously unseen in the 8/16-bit micro- controller market. the mplab ide is a windows ? based application that contains:  an interface to debugging tools - simulator - programmer (sold separately) - emulator (sold separately) - in-circuit debugger (sold separately)  a full-featured editor with color coded context  a multiple project manager  customizable data windows with direct edit of contents  high level source code debugging  mouse over variable inspection  extensive on-line help the mplab ide allows you to:  edit your source files (either assembly or c)  one touch assemble (or compile) and download to picmicro emulator and simulator tools (automatically updates all project information)  debug using: - source files (assembly or c) - absolute listing file (mixed assembly and c) - machine code mplab ide supports multiple debugging tools in a single development paradigm, from the cost effective simulators, through low cost in-circuit debuggers, to full-featured emulators. this eliminates the learning curve when upgrading to tools with increasing flexibility and power. 14.2 mpasm assembler the mpasm assembler is a full-featured, universal macro assembler for all picmicro mcus. the mpasm assembler generates relocatable object files for the mplink object linker, intel ? standard hex files, map files to detail memory usage and symbol ref- erence, absolute lst files that contain source lines and generated machine code and coff files for debugging. the mpasm assembler features include:  integration into mplab ide projects  user defined macros to streamline assembly code  conditional assembly for multi-purpose source files  directives that allow complete control over the assembly process
PIC12F683 ds41211a-page 110 advance information ? 2003 microchip technology inc. 14.3 mplab c17 and mplab c18 c compilers the mplab c17 and mplab c18 code development systems are complete ansi c compilers for microchip?s pic17cxxx and pic18cxxx family of microcontrollers. these compilers provide powerful integration capabilities, superior code optimization and ease of use not found with other compilers. for easy source level debugging, the compilers provide symbol information that is optimized to the mplab ide debugger. 14.4 mplink object linker/ mplib object librarian the mplink object linker combines relocatable objects created by the mpasm assembler and the mplab c17 and mplab c18 c compilers. it can link relocatable objects from pre-compiled libraries, using directives from a linker script. the mplib object librarian manages the creation and modification of library files of pre-compiled code. when a routine from a library is called from a source file, only the modules that contain that routine will be linked in with the application. this allows large libraries to be used efficiently in many different applications. the object linker/library features include:  efficient linking of single libraries instead of many smaller files  enhanced code maintainability by grouping related modules together  flexible creation of libraries with easy module listing, replacement, deletion and extraction 14.5 mplab c30 c compiler the mplab c30 c compiler is a full-featured, ansi compliant, optimizing compiler that translates standard ansi c programs into dspic30f assembly language source. the compiler also supports many command- line options and language extensions to take full advantage of the dspic30f device hardware capabili- ties, and afford fine control of the compiler code generator. mplab c30 is distributed with a complete ansi c standard library. all library functions have been vali- dated and conform to the ansi c library standard. the library includes functions for string manipulation, dynamic memory allocation, data conversion, time- keeping, and math functions (trigonometric, exponen- tial and hyperbolic). the compiler provides symbolic information for high level source debugging with the mplab ide. 14.6 mplab asm30 assembler, linker, and librarian mplab asm30 assembler produces relocatable machine code from symbolic assembly language for dspic30f devices. mplab c30 compiler uses the assembler to produce it?s object file. the assembler generates relocatable object files that can then be archived or linked with other relocatable object files and archives to create an executable file. notable features of the assembler include:  support for the entire dspic30f instruction set  support for fixed-point and floating-point data  command line interface  rich directive set  flexible macro language  mplab ide compatibility 14.7 mplab sim software simulator the mplab sim software simulator allows code devel- opment in a pc hosted environment by simulating the picmicro series microcontrollers on an instruction level. on any given instruction, the data areas can be examined or modified and stimuli can be applied from a file, or user defined key press, to any pin. the execu- tion can be performed in single-step, execute until break, or trace mode. the mplab sim simulator fully supports symbolic debugging using the mplab c17 and mplab c18 c compilers, as well as the mpasm assembler. the software simulator offers the flexibility to develop and debug code outside of the laboratory environment, making it an excellent, economical software development tool. 14.8 mplab sim30 software simulator the mplab sim30 software simulator allows code development in a pc hosted environment by simulating the dspic30f series microcontrollers on an instruction level. on any given instruction, the data areas can be examined or modified and stimuli can be applied from a file, or user defined key press, to any of the pins. the mplab sim30 simulator fully supports symbolic debugging using the mplab c30 c compiler and mplab asm30 assembler. the simulator runs in either a command line mode for automated tasks, or from mplab ide. this high speed simulator is designed to debug, analyze and optimize time intensive dsp routines.
? 2003 microchip technology inc. advance information ds41211a-page 111 PIC12F683 14.9 mplab ice 2000 high performance universal in-circuit emulator the mplab ice 2000 universal in-circuit emulator is intended to provide the product development engineer with a complete microcontroller design tool set for picmicro microcontrollers. software control of the mplab ice 2000 in-circuit emulator is advanced by the mplab integrated development environment, which allows editing, building, downloading and source debugging from a single environment. the mplab ice 2000 is a full-featured emulator sys- tem with enhanced trace, trigger and data monitoring features. interchangeable processor modules allow the system to be easily reconfigured for emulation of differ- ent processors. the universal architecture of the mplab ice in-circuit emulator allows expansion to support new picmicro microcontrollers. the mplab ice 2000 in-circuit emulator system has been designed as a real-time emulation system with advanced features that are typically found on more expensive development tools. the pc platform and microsoft ? windows 32-bit operating system were chosen to best make these features available in a simple, unified application. 14.10 mplab ice 4000 high performance universal in-circuit emulator the mplab ice 4000 universal in-circuit emulator is intended to provide the product development engineer with a complete microcontroller design tool set for high- end picmicro microcontrollers. software control of the mplab ice in-circuit emulator is provided by the mplab integrated development environment, which allows editing, building, downloading and source debugging from a single environment. the mplab icd 4000 is a premium emulator system, providing the features of mplab ice 2000, but with increased emulation memory and high speed perfor- mance for dspic30f and pic18xxxx devices. its advanced emulator features include complex triggering and timing, up to 2 mb of emulation memory, and the ability to view variables in real-time. the mplab ice 4000 in-circuit emulator system has been designed as a real-time emulation system with advanced features that are typically found on more expensive development tools. the pc platform and microsoft windows 32-bit operating system were cho- sen to best make these features available in a simple, unified application. 14.11 mplab icd 2 in-circuit debugger microchip?s in-circuit debugger, mplab icd 2, is a powerful, low cost, run-time development tool, connecting to the host pc via an rs-232 or high speed usb interface. this tool is based on the flash picmicro mcus and can be used to develop for these and other picmicro microcontrollers. the mplab icd 2 utilizes the in-circuit debugging capability built into the flash devices. this feature, along with microchip?s in-circuit serial programming tm (icsp tm ) protocol, offers cost effective in-circuit flash debugging from the graphical user interface of the mplab inte- grated development environment. this enables a designer to develop and debug source code by setting breakpoints, single-stepping and watching variables, cpu status and peripheral registers. running at full speed enables testing hardware and applications in real-time. mplab icd 2 also serves as a development programmer for selected picmicro devices. 14.12 pro mate ii universal device programmer the pro mate ii is a universal, ce compliant device programmer with programmable voltage verification at v ddmin and v ddmax for maximum reliability. it features an lcd display for instructions and error messages and a modular detachable socket assembly to support various package types. in stand-alone mode, the pro mate ii device programmer can read, verify, and program picmicro devices without a pc connection. it can also set code protection in this mode. 14.13 picstart plus development programmer the picstart plus development programmer is an easy-to-use, low cost, prototype programmer. it con- nects to the pc via a com (rs-232) port. mplab integrated development environment software makes using the programmer simple and efficient. the picstart plus development programmer supports most picmicro devices up to 40 pins. larger pin count devices, such as the pic16c92x and pic17c76x, may be supported with an adapter socket. the picstart plus development programmer is ce compliant.
PIC12F683 ds41211a-page 112 advance information ? 2003 microchip technology inc. 14.14 picdem 1 picmicro demonstration board the picdem 1 demonstration board demonstrates the capabilities of the pic16c5x (pic16c54 to pic16c58a), pic16c61, pic16c62x, pic16c71, pic16c8x, pic17c42, pic17c43 and pic17c44. all necessary hardware and software is included to run basic demo programs. the sample microcontrollers provided with the picdem 1 demonstration board can be programmed with a pro mate ii device program- mer, or a picstart plus development programmer. the picdem 1 demonstration board can be connected to the mplab ice in-circuit emulator for testing. a pro- totype area extends the circuitry for additional applica- tion components. features include an rs-232 interface, a potentiometer for simulated analog input, push button switches and eight leds. 14.15 picdem.net internet/ethernet demonstration board the picdem.net demonstration board is an internet/ ethernet demonstration board using the pic18f452 microcontroller and tcp/ip firmware. the board supports any 40-pin dip device that conforms to the standard pinout used by the pic16f877 or pic18c452. this kit features a user friendly tcp/ip stack, web server with html, a 24l256 serial eeprom for xmodem download to web pages into serial eeprom, icsp/mplab icd 2 interface con- nector, an ethernet interface, rs-232 interface, and a 16 x 2 lcd display. also included is the book and cd-rom ?tcp/ip lean, web servers for embedded systems,? by jeremy bentham. 14.16 picdem 2 plus demonstration board the picdem 2 plus demonstration board supports many 18-, 28-, and 40-pin microcontrollers, including pic16f87x and pic18fxx2 devices. all the neces- sary hardware and software is included to run the dem- onstration programs. the sample microcontrollers provided with the picdem 2 demonstration board can be programmed with a pro mate ii device program- mer, picstart plus development programmer, or mplab icd 2 with a universal programmer adapter. the mplab icd 2 and mplab ice in-circuit emulators may also be used with the picdem 2 demonstration board to test firmware. a prototype area extends the circuitry for additional application components. some of the features include an rs-232 interface, a 2 x 16 lcd display, a piezo speaker, an on-board temperature sensor, four leds, and sample pic18f452 and pic16f877 flash microcontrollers. 14.17 picdem 3 pic16c92x demonstration board the picdem 3 demonstration board supports the pic16c923 and pic16c924 in the plcc package. all the necessary hardware and software is included to run the demonstration programs. 14.18 picdem 4 8/14/18-pin demonstration board the picdem 4 can be used to demonstrate the capa- bilities of the 8-, 14-, and 18-pin pic16xxxx and pic18xxxx mcus, including the pic16f818/819, pic16f87/88, pic16f62xa and the pic18f1320 fam- ily of microcontrollers. picdem 4 is intended to show- case the many features of these low pin count parts, including lin and motor control using eccp. special provisions are made for low power operation with the supercapacitor circuit, and jumpers allow on-board hardware to be disabled to eliminate current draw in this mode. included on the demo board are provisions for crystal, rc or canned oscillator modes, a five volt regulator for use with a nine volt wall adapter or battery, db-9 rs-232 interface, icd connector for program- ming via icsp and development with mplab icd 2, 2x16 liquid crystal display, pcb footprints for h-bridge motor driver, lin transceiver and eeprom. also included are: header for expansion, eight leds, four potentiometers, three push buttons and a prototyping area. included with the kit is a pic16f627a and a pic18f1320. tutorial firmware is included along with the user?s guide. 14.19 picdem 17 demonstration board the picdem 17 demonstration board is an evaluation board that demonstrates the capabilities of several microchip microcontrollers, including pic17c752, pic17c756a, pic17c762 and pic17c766. a pro- grammed sample is included. the pro mate ii device programmer, or the picstart plus development pro- grammer, can be used to reprogram the device for user tailored application development. the picdem 17 demonstration board supports program download and execution from external on-board flash memory. a generous prototype area is available for user hardware expansion.
? 2003 microchip technology inc. advance information ds41211a-page 113 PIC12F683 14.20 picdem 18r pic18c601/801 demonstration board the picdem 18r demonstration board serves to assist development of the pic18c601/801 family of microchip microcontrollers. it provides hardware implementation of both 8-bit multiplexed/de-multiplexed and 16-bit memory modes. the board includes 2 mb external flash memory and 128 kb sram memory, as well as serial eeprom, allowing access to the wide range of memory types supported by the pic18c601/801. 14.21 picdem lin pic16c43x demonstration board the powerful lin hardware and software kit includes a series of boards and three picmicro microcontrollers. the small footprint pic16c432 and pic16c433 are used as slaves in the lin communication and feature on-board lin transceivers. a pic16f874 flash micro- controller serves as the master. all three microcontrol- lers are programmed with firmware to provide lin bus communication. 14.22 pickit tm 1 flash starter kit a complete ?development system in a box?, the pickit flash starter kit includes a convenient multi-section board for programming, evaluation, and development of 8/14-pin flash pic ? microcontrollers. powered via usb, the board operates under a simple windows gui. the pickit 1 starter kit includes the user's guide (on cd rom), pickit 1 tutorial software and code for vari- ous applications. also included are mplab ? ide (inte- grated development environment) software, software and hardware ?tips 'n tricks for 8-pin flash pic ? microcontrollers? handbook and a usb interface cable. supports all current 8/14-pin flash pic microcontrollers, as well as many future planned devices. 14.23 picdem usb pic16c7x5 demonstration board the picdem usb demonstration board shows off the capabilities of the pic16c745 and pic16c765 usb microcontrollers. this board provides the basis for future usb products. 14.24 evaluation and programming tools in addition to the picdem series of circuits, microchip has a line of evaluation kits and demonstration software for these products. k ee l oq evaluation and programming tools for microchip?s hcs secure data products  can developers kit for automotive network applications  analog design boards and filter design software  powersmart battery charging evaluation/ calibration kits irda ? development kit  microid development and rflab tm development software  seeval ? designer kit for memory evaluation and endurance calculations  picdem msc demo boards for switching mode power supply, high power ir driver, delta sigma adc, and flow rate sensor check the microchip web page and the latest product line card for the complete list of demonstration and evaluation kits.
PIC12F683 ds41211a-page 114 advance information ? 2003 microchip technology inc. notes:
? 2003 microchip technology inc. advance information ds41211a-page 115 PIC12F683 15.0 electrical specifications absolute maximum ratings (?) ambient temperature under bias................................................................................................. .......... -40 to +125c storage temperature ............................................................................................................ ............ -65c to +150c voltage on v dd with respect to v ss ...................................................................................................... -0.3 to +6.5v voltage on mclr with respect to vss ..................................................................................................-0.3 to +13.5v voltage on all other pins with respect to v ss ........................................................................... -0.3v to (v dd + 0.3v) total power dissipation (1) ............................................................................................................................... 800 mw maximum current out of v ss pin ..................................................................................................................... 300 ma maximum current into v dd pin ........................................................................................................................ 250 ma input clamp current, i ik (v i < 0 or v i > v dd ) ............................................................................................................... 20 ma output clamp current, i ok (vo < 0 or vo >v dd ) ......................................................................................................... 20 ma maximum output current sunk by any i/o pin..................................................................................... ............... 25 ma maximum output current sourced by any i/o pin .................................................................................. ............ 25 ma maximum current sunk by gpio ................................................................................................... .................. 200 ma maximum current sourced gpio................................................................................................... .................. 200 ma note 1: power dissipation is calculated as follows: p dis = v dd x {i dd - i oh } + {(v dd -v oh ) x i oh } + (v o l x i ol ). ? notice: stresses above those listed under ?absolute maximum ratings? may cause permanent damage to the device. this is a stress rating only and functional operation of the device at those or any other conditions above those indicated in the operation listings of this specification is not implied. exposure to maximum rating conditions for extended periods may affect device reliability. note: voltage spikes below v ss at the mclr pin, inducing currents greater than 80 ma, may cause latch-up. thus, a series resistor of 50-100  should be used when applying a ?low? level to the mclr pin, rather than pulling this pin directly to v ss .
PIC12F683 ds41211a-page 116 advance information ? 2003 microchip technology inc. figure 15-1: PIC12F683 with a/d disabled voltage-frequency graph, -40c  t a  +125c figure 15-2: PIC12F683 with a/d enabled voltage-frequency graph, -40c  t a  +125c 5.5 2.0 3.5 2.5 0 3.0 4.0 4.5 5.0 4 frequency (mhz) v dd (volts) note 1: the shaded region indicates the permissible combinations of voltage and frequency. 816 12 20 10 5.5 2.0 3.5 2.5 0 3.0 4.0 4.5 5.0 4 frequency (mhz) v dd (volts) note 1: the shaded region indicates the permissible combinations of voltage and frequency. 816 12 20 10
? 2003 microchip technology inc. advance information ds41211a-page 117 PIC12F683 figure 15-3: PIC12F683 with a/d enabled voltage-frequency graph, 0c  t a  +125c 5.5 2.0 3.5 2.5 0 3.0 4.0 4.5 5.0 4 frequency (mhz) v dd (volts) note 1: the shaded region indicates the permissible combinations of voltage and frequency. 816 12 20 10 2.2
PIC12F683 ds41211a-page 118 advance information ? 2003 microchip technology inc. 15.1 dc characteristics: PIC12F683-i (industrial), PIC12F683-e (extended) dc characteristics standard operating conditions (unless otherwise stated) operating temperature -40c  t a  +85c for industrial -40c  t a  +125c for extended param no. sym characteristic min typ? max units conditions d001 d001a d001b d001c d001d v dd supply voltage 2.0 2.2 2.5 3.0 4.5 ? ? ? ? ? 5.5 5.5 5.5 5.5 5.5 v v v v v f osc < = 4 mhz: a/d off a/d on, 0c to +125c a/d on, -40c to +125c f osc < = 10 mhz f osc < = 20 mhz d002 v dr ram data retention voltage (1) 1.5* ? ? v device in sleep mode d003 v por v dd start voltage to ensure internal power-on reset signal ?v ss ? v see section on power-on reset for details d004 s vdd v dd rise rate to ensure internal power-on reset signal 0.05* ? ? v/ms see section on power-on reset for details d005 v bod brown-out detect ?2.1? v * these parameters are characterized but not tested. ? data in ?typ? column is at 5.0v, 25c unless otherwise stated. these parameters are for design guidance only and are not tested. note 1: this is the limit to which v dd can be lowered in sleep mode without losing ram data.
? 2003 microchip technology inc. advance information ds41211a-page 119 PIC12F683 15.2 dc characteristics: PIC12F683-i (industrial) dc characteristics standard operating conditions (unless otherwise stated) operating temperature -40c  t a  +85c for industrial param no. device characteristics min typ? max units conditions v dd note d010 supply current (i dd ) ?9 tbd a2.0f osc = 32 khz lp oscillator mode ?18 tbd a3.0 ?35 tbd a5.0 d011 ? 110 tbd a2.0f osc = 1 mhz xt oscillator mode ?190 tbd a3.0 ?330 tbd a5.0 d012 ? 220 tbd a2.0f osc = 4 mhz xt oscillator mode ?370 tbd a3.0 ?0.6 tbd ma 5.0 d013 ? 70 tbd a2.0f osc = 1 mhz ec oscillator mode ?140 tbd a3.0 ?260 tbd a5.0 d014 ? 180 tbd a2.0f osc = 4 mhz ec oscillator mode ?320 tbd a3.0 ?580 tbd a5.0 d015 ? 10 tbd a2.0f osc = 31 khz intrc mode ?25 tbd a3.0 ?40 tbd a5.0 d016 ? 340 tbd a2.0f osc = 4 mhz intosc mode ?500 tbd a3.0 ?0.8 tbd ma 5.0 d017 ? 250 tbd a2.0f osc = 4 mhz extrc mode ?375 tbd a3.0 ?750 tbd a5.0 d018 ? 3.0 tbd ma 4.5 f osc = 20 mhz hs oscillator mode ?3.7 tbd ma 5.0 ? data in ?typ? column is at 5.0v, 25 c unless otherwise stated. these parameters are for design guidance only and are not tested. note 1: the test conditions for all i dd measurements in active operation mode are: osc1 = external square wave, from rail to rail; all i/o pins tri-stated, pulled to v dd ; mclr = v dd ; wdt disabled. 2: the supply current is mainly a function of the operating voltage and frequency. other factors such as i/o pin loading and switching rate, oscillator type, internal code execution pattern, and temperature also have an impact on the current consumption.
PIC12F683 ds41211a-page 120 advance information ? 2003 microchip technology inc. 15.2 dc characteristics: PIC12F683-i (industrial) (continued) dc characteristics standard operating conditions (unless otherwise stated) operating temperature -40 c  t a  +85 c for industrial param no. device characteristics min typ? max units conditions v dd note d020 power-down base current (i pd ) ?0.99 tbd na 2.0 wdt, bod, comparator, v ref , and t1osc disabled ?1.2 tbd na 3.0 ?2.9 tbd na 5.0 d021 ? 1.8 tbd a 2.0 wdt current (1) ?2.7 tbd a3.0 ?8.4 tbd a5.0 d022 ? 58 tbd a 3.0 bod current (1) ?109 tbd a5.0 d023 ? 18 tbd a 2.0 comparator current (1) ?28 tbd a3.0 ?60 tbd a5.0 d024 ? 58 tbd a2.0cv ref current (1) ?85 tbd a3.0 ?138 tbd a5.0 d025 ? 7.0 tbd a 2.0 t1 o sc current (1) ?8.6 tbd a3.0 ?10 tbd a5.0 d026 ? 1.2 tbd na 3.0 a/d current (1) ?0.0029 tbd a5.0 ? data in ?typ? column is at 5.0v, 25 c unless otherwise stated. these parameters are for design guidance only and are not tested. note 1: the peripheral current is the sum of the base i dd or i pd and the additional current consumed when this peripheral is enabled. the peripheral  current can be determined by subtracting the base i dd or i pd current from this limit. max values should be used when calculating total current consumption. 2: the power-down current in sleep mode does not depend on the oscillator type. power-down current is measured with the part in sleep mode, with all i/o pins in hi-impedance state and tied to v dd .
? 2003 microchip technology inc. advance information ds41211a-page 121 PIC12F683 15.3 dc characteristics: PIC12F683 -e (extended) dc characteristics standard operating conditions (unless otherwise stated) operating temperature -40 c  t a  +125 c for extended param no. device characteristics min typ? max units conditions v dd note d010e supply current (i dd ) ?9 tbd a2.0f osc = 32 khz lp oscillator mode ?18 tbd a3.0 ?35 tbd a5.0 d011e ? 110 tbd a2.0f osc = 1 mhz xt oscillator mode ?190 tbd a3.0 ?330 tbd a5.0 d012e ? 220 tbd a2.0f osc = 4 mhz xt oscillator mode ?370 tbd a3.0 ?0.6 tbd ma 5.0 d013e ? 70 tbd a2.0f osc = 1 mhz ec oscillator mode ?140 tbd a3.0 ?260 tbd a5.0 d014e ? 180 tbd a2.0f osc = 4 mhz ec oscillator mode ?320 tbd a3.0 ?580 tbd a5.0 d015e ? 10 tbd a2.0f osc = 31 khz intrc mode ?25 tbd a3.0 ?40 tbd a5.0 d016e ? 340 tbd a2.0f osc = 4 mhz intosc mode ?500 tbd a3.0 ?0.8 tbd ma 5.0 d017e ? 250 tbd a2.0f osc = 4 mhz extrc mode ?375 tbd a3.0 ?750 tbd a5.0 d018e ? 3.0 tbd ma 4.5 f osc = 20 mhz hs oscillator mode ?3.7 tbd ma 5.0 ? data in ?typ? column is at 5.0v, 25 c unless otherwise stated. these parameters are for design guidance only and are not tested. note 1: the test conditions for all i dd measurements in active operation mode are: osc1 = external square wave, from rail to rail; all i/o pins tri-stated, pulled to v dd ; mclr = v dd ; wdt disabled. 2: the supply current is mainly a function of the operating voltage and frequency. other factors such as i/o pin loading and switching rate, oscillator type, internal code execution pattern, and temperature also have an impact on the current consumption.
PIC12F683 ds41211a-page 122 advance information ? 2003 microchip technology inc. 15.4 dc characteristics: PIC12F683 -e (extended) (continued) dc characteristics standard operating conditions (unless otherwise stated) operating temperature -40 c  t a  +125 c for extended param no. device characteristics min typ? max units conditions v dd note d020e power-down base current (i pd ) ?0.99 tbd na 2.0 wdt, bod, comparator, v ref , and t1osc disabled ?1.2 tbd na 3.0 ?2.9 tbd na 5.0 d021e ? 1.8 tbd a 2.0 wdt current (1) ?2.7 tbd a3.0 ?8.4 tbd a5.0 d022e ? 58 tbd a 3.0 bod current (1) ?109 tbd a5.0 d023e ? 18 tbd a 2.0 comparator current (1) ?28 tbd a3.0 ?60 tbd a5.0 d024e ? 58 tbd a2.0cv ref current (1) ?85 tbd a3.0 ?138 tbd a5.0 d025e ? 7.0 tbd a 2.0 t1 o sc current (1) ?8.6 tbd a3.0 ?10 tbd a5.0 d026e ? 1.2 tbd a 3.0 a/d current (1) ?0.0029 tbd a5.0 ? data in ?typ? column is at 5.0v, 25 c unless otherwise stated. these parameters are for design guidance only and are not tested. note 1: the peripheral current is the sum of the base i dd or i pd and the additional current consumed when this peripheral is enabled. the peripheral  current can be determined by subtracting the base i dd or i pd current from this limit. max values should be used when calculating total current consumption. 2: the power-down current in sleep mode does not depend on the oscillator type. power-down current is measured with the part in sleep mode, with all i/o pins in hi-impedance state and tied to v dd .
? 2003 microchip technology inc. advance information ds41211a-page 123 PIC12F683 15.5 dc characteristics: PIC12F683-i (industrial), PIC12F683-e (extended) dc characteristics standard operating conditions (unless otherwise stated) operating temperature -40c  t a  +85c for industrial -40c  t a  +125c for extended param no. sym characteristic min typ? max units conditions input low voltage v il i/o port d030 with ttl buffer vss ? 0.8 v 4.5v  v dd  5.5v d030a vss ? 0.15 v dd v otherwise d031 with schmitt trigger buffer vss ? 0.2 v dd v entire range tbd ultra-low power ? ? ? ? d032 mclr , osc1 (rc mode) v ss ? 0.2 v dd v d033 osc1 (xt and lp modes) (1) v ss ?0.3v d033a osc1 (hs mode) (1) v ss ? 0.3 v dd v input high voltage v ih i/o port ? d040 d040a with ttl buffer 2.0 (0.25 v dd +0.8) ? ? v dd v dd v v 4.5v  v dd  5.5v otherwise d041 with schmitt trigger buffer 0.8 v dd ?v dd v entire range tbd ultra-low power ? ? ? ? d042 mclr 0.8 v dd ?v dd v d043 osc1 (xt and lp modes) 1.6 ? v dd v (note 1) d043a osc1 (hs mode) 0.7 v dd ?v dd v (note 1) d043b osc1 (rc mode) 0.9 v dd ?v dd v d070 i pur gpio weak pull-up current 50* 250 400* a v dd = 5.0v, v pin = v ss input leakage current (2) d060 i il i/o port ? 0 . 1 1 a v ss  v pin  v dd , pin at hi-impedance d060a analog inputs ? 0 . 1 1 a v ss  v pin  v dd d060b v ref ? 0 . 1 1 a v ss  v pin  v dd d061 mclr (3) ? 0 . 1 5 a v ss  v pin  v dd d063 osc1 ? 0 . 1 5 a v ss  v pin  v dd , xt, hs and lp oscillator configuration output low voltage d080 v ol i/o port ? ? 0.6 v i ol = 8.5 ma, v dd = 4.5v (ind.) d083 osc2/clkout (rc mode) ? ? 0.6 v i ol = 1.6 ma, v dd = 4.5v (ind.) i ol = 1.2 ma, v dd = 4.5v (ext.) output high voltage d090 v oh i/o port v dd - 0.7 ? ? v i oh = -3.0 ma, v dd = 4.5v (ind.) d092 osc2/clkout (rc mode) v dd - 0.7 ? ? v i oh = -1.3 ma, v dd = 4.5v (ind.) i oh = -1.0 ma, v dd = 4.5v (ext.) * these parameters are characterized but not tested. ? data in ?typ? column is at 5.0v, 25 c unless otherwise stated. these parameters are for design guidance only and are not tested. note 1: in rc oscillator configuration, the osc1/clkin pin is a schmitt trigger input. it is not recommended to use an external clock in rc mode. 2: negative current is defined as current sourced by the pin. 3: the leakage current on the mclr pin is strongly dependent on the applied voltage level. the specified levels represent normal operating conditions. higher leakage current may be measured at different input voltages.
PIC12F683 ds41211a-page 124 advance information ? 2003 microchip technology inc. 15.5 dc characteristics: PIC12F683-i (industrial), PIC12F683-e (extended) (continued) dc characteristics standard operating conditions (unless otherwise stated) operating temperature - 40c  t a  +85c for industrial -40c  t a  +125c for extended param no. sym characteristic min typ? max units conditions d100 i ulp ultra low-power wake-up current ?200?na capacitive loading specs on output pins d100 cosc2 osc2 pin ? ? 15* pf in xt, hs and lp modes when external clock is used to drive osc1 d101 c io all i/o pins ? ? 50* pf data eeprom memory d120 e d byte endurance 100k 1m ? e/w -40 c  t a  +85c d120a e d byte endurance 10k 100k ? e/w +85c  t a  +125c d121 v drw v dd for read/write v min ? 5.5 v using eecon1 to read/write v min = minimum operating voltage d122 t dew erase/write cycle time ? 5 6 ms d123 t retd characteristic retention 40 ? ? year provided no other specifications are violated d124 t ref number of total erase/write cycles before refresh (1) 1m 10m ? e/w -40 c  t a  +85c program flash memory d130 e p cell endurance 10k 100k ? e/w -40 c  t a  +85c d130a e d cell endurance 1k 10k ? e/w +85c  t a  +125c d131 v pr v dd for read v min ?5.5vv min = minimum operating voltage d132 v pew v dd for erase/write 4.5 ? 5.5 v d133 t pew erase/write cycle time ? 2 2.5 ms d134 t retd characteristic retention 40 ? ? year provided no other specifications are violated * these parameters are characterized but not tested. ? data in ?typ? column is at 5.0v, 25 c unless otherwise stated. these parameters are for design guidance only and are not tested. note 1: see section 11.4.1 ?using the data eeprom? for additional information.
? 2003 microchip technology inc. advance information ds41211a-page 125 PIC12F683 15.6 timing parameter symbology the timing parameter symbols have been created with one of the following formats: figure 15-4: load conditions 1. tpps2pps 2. tpps t f frequency t time lowercase letters (pp) and their meanings: pp cc ccp1 osc osc1 ck clkout rd rd cs cs rw rd or wr di sdi sc sck do sdo ss ss dt data in t0 t0cki io i/o port t1 t1cki mc mclr wr wr uppercase letters and their meanings: s ffall pperiod hhigh rrise i invalid (hi-impedance) v valid l low z hi-impedance v dd /2 c l r l pin pin v ss v ss c l r l =464  c l = 50 pf for all pins 15 pf for osc2 output load condition 1 load condition 2
PIC12F683 ds41211a-page 126 advance information ? 2003 microchip technology inc. 15.7 ac characteristics: PIC12F683 (industrial, extended) figure 15-5: external clock timing table 15-1: external clock timing requirements standard operating conditions (unless otherwise stated) operating temperature -40c  t a  +125c param no. sym characteristic min typ? max units conditions f osc external clkin frequency (1) dc ? 37 khz lp oscillator mode dc ? 4 mhz xt mode dc ? 20 mhz hs mode dc ? 20 mhz ec mode oscillator frequency (1) 5 ? 37 khz lp oscillator mode ?4 ?mhzintosc mode dc ? 4 mhz rc oscillator mode 0.1 ? 4 mhz xt oscillator mode 1 ? 20 mhz hs oscillator mode 1t osc external clkin period (1) 27 ?  s lp oscillator mode 50 ?  ns hs oscillator mode 50 ?  ns ec oscillator mode 250 ?  ns xt oscillator mode oscillator period (1) 27 ? 200 s lp oscillator mode ?250 ? nsintosc mode 250 ? ? ns rc oscillator mode 250 ? 10,000 ns xt oscillator mode 50 ? 1,000 ns hs oscillator mode 2t cy instruction cycle time (1) 200 t cy dc ns t cy = 4/f osc 3 tosl, to sh external clkin (osc1) high external clkin low 2* ? ? s lp oscillator, t osc l/h duty cycle 20* ? ? ns hs oscillator, t osc l/h duty cycle 100 * ? ? ns xt oscillator, t osc l/h duty cycle 4tosr, to sf external clkin rise external clkin fall ? ? 50* ns lp oscillator ? ? 25* ns xt oscillator ? ? 15* ns hs oscillator * these parameters are characterized but not tested. ? data in ?typ? column is at 5v, 25c unless otherwise stated. these parameters are for design guidance only and are not tested. note 1: instruction cycle period (t cy ) equals four times the input oscillator time base period. all specified values are based on characterization data for that particular oscillator type under standard operating conditions with the device executing code. exceeding these specified limits may result in an unstable oscillator operation and/or higher than expected current consumption. all devices are tested to operate at ?min? values with an external clock applied to osc1 pin. when an external clock input is used, the ?max? cycle time limit is ?dc? (no clock) for all devices. osc1 clkout q4 q1 q2 q3 q4 q1 1 2 3 3 4 4
? 2003 microchip technology inc. advance information ds41211a-page 127 PIC12F683 table 15-2: precision internal oscillator parameters standard operating conditions (unless otherwise stated) operating temperature -40c  t a  +125c param no. sym characteristic freq tolerance min typ? max units conditions f10 f osc internal calibrated intosc frequency (1) 1% 3.96 4.00 4.04 mhz v dd and temperature tbd 2% 3.92 4.00 4.08 mhz 2.5v  v dd  5.5v 0 c  t a  +85 c 5% 3.80 4.00 4.20 mhz 2.0v  v dd  5.5v -40 c  t a  +85 c (ind.) -40 c  t a  +125 c (ext.) f14 t iosc st oscillator wake-up from sleep start-up time* ?? tbd tbd sv dd = 2.0v, -40 c to +85 c ?? tbd tbd sv dd = 3.0v, -40 c to +85 c ?? tbd tbd sv dd = 5.0v, -40 c to +85 c * these parameters are characterized but not tested. ? data in ?typ? column is at 5.0v, 25 c unless otherwise stated. these parameters are for design guidance only and are not tested. note 1: to ensure these oscillator frequency tolerances, v dd and v ss must be capacitively decoupled as close to the device as possible. 0.1 uf and 0.01 uf values in parallel are recommended.
PIC12F683 ds41211a-page 128 advance information ? 2003 microchip technology inc. figure 15-6: clkout and i/o timing table 15-3: clkout and i/o timing requirements standard operating conditions (unless otherwise stated) operating temperature -40c  t a  +125c param no. sym characteristic min typ? max units conditions 10 tosh2ckl osc1  to clout ? 75 200 ns (note 1) 11 tosh2ckh osc1  to clout  ? 75 200 ns (note 1) 12 tckr clkout rise time ? 35 100 ns (note 1) 13 tckf clkout fall time ? 35 100 ns (note 1) 14 tckl2iov clkout to port out valid ? ? 20 ns (note 1) 15 tiov2ckh port in valid before clkout  t osc + 200 ns ? ? ns (note 1) 16 tckh2ioi port in hold after clkout  0 ? ? ns (note 1) 17 tosh2iov osc1  (q1 cycle) to port out valid ? 50 150 * ns ? ? 300 ns 18 tosh2ioi osc1  (q2 cycle) to port input invalid (i/o in hold time) 100 ? ? ns 19 tiov2osh port input valid to osc1  (i/o in setup time) 0??ns 20 tior port output rise time ? 10 40 ns 21 tiof port output fall time ? 10 40 ns 22 tinp int pin high or low time 25 ? ? ns 23 trbp gpio change int high or low time t cy ??ns * these parameters are characterized but not tested. ? data in ?typ? column is at 5.0v, 25 c unless otherwise stated. note 1: measurements are taken in rc mode where clkout output is 4xt osc . osc1 clkout i/o pin (input) i/o pin (output) q4 q1 q2 q3 10 13 14 17 20, 21 22 23 19 18 15 11 12 16 old value new value
? 2003 microchip technology inc. advance information ds41211a-page 129 PIC12F683 figure 15-7: reset, watchdog timer, oscillator start-up timer and power-up timer timing figure 15-8: brown-out detect timing and characteristics v dd mclr internal por pwrt time-out osc time-out internal reset watchdog timer reset 33 32 30 31 34 i/o pins 34 b vdd reset (due to bod) v dd (device in brown-out detect) (device not in brown-out detect) 64 ms time-out (1) 35 note 1: 64 ms delay only if pwrte bit in configuration word is programmed to ? 0 ?.
PIC12F683 ds41211a-page 130 advance information ? 2003 microchip technology inc. table 15-4: reset, watchdog timer, oscillator start-up timer, power-up timer, and brown-out detect requirements standard operating conditions (unless otherwise stated) operating temperature -40c  t a  +125c param no. sym characteristic min typ? max units conditions 30 t mc lmclr pulse width (low) 2 11 ? 18 ? 24 s ms v dd = 5v, -40c to +85c extended temperature 31 t wdt watchdog timer time-out period (no prescaler) 10 10 17 17 25 30 ms ms v dd = 5v, -40c to +85c extended temperature 32 t ost oscillation start-up timer period ? 1024t osc ??t osc = osc1 period 33* t pwrt power-up timer period 28* tbd 64 tbd 132* tbd ms ms v dd = 5v, -40c to +85c extended temperature 34 t ioz i/o hi-impedance from mclr low or watchdog timer reset ??2.0 s b vdd brown-out detect voltage 2.025 ? 2.175 v 35 t bod brown-out detect pulse width 100* ? ? sv dd  b vdd (d005) 36 t r brown-out detect response time ?? 1 s 37 t rd brown-out detect retriggerable delay time 51015 s * these parameters are characterized but not tested. ? data in ?typ? column is at 5v, 25c unless otherwise stated. these parameters are for design guidance only and are not tested.
? 2003 microchip technology inc. advance information ds41211a-page 131 PIC12F683 figure 15-9: timer0 and timer1 external clock timings table 15-5: timer0 and timer1 external clock requirements standard operating conditions (unless otherwise stated) operating temperature -40c  t a  +125c param no. sym characteristic min typ? max units conditions 40* tt0h t0cki high-pulse width no prescaler 0.5 t cy + 20 ? ? ns with prescaler 10 ? ? ns 41* tt0l t0cki low-pulse width no prescaler 0.5 t cy + 20 ? ? ns with prescaler 10 ? ? ns 42* tt0p t0cki period greater of: 20 or t cy + 40 n ? ? ns n = prescale value (2, 4, ..., 256) 45* tt1h t1cki high time synchronous, no prescaler 0.5 t cy + 20 ? ? ns synchronous, with prescaler 15 ? ? ns asynchronous 30 ? ? ns 46* tt1l t1cki low time synchronous, no prescaler 0.5 t cy + 20 ? ? ns synchronous, with prescaler 15 ? ? ns asynchronous 30 ? ? ns 47* tt1p t1cki input period synchronous greater of: 30 or t cy + 40 n ? ? ns n = prescale value (1, 2, 4, 8) asynchronous 60 ? ? ns ft1 timer1 oscillator input frequency range (oscillator enabled by setting bit t1oscen) dc ? 200* khz 48 tckeztmr1 delay from external clock edge to timer increment 2 t osc *?7 t osc * ? * these parameters are characterized but not tested. ? data in ?typ? column is at 5v, 25c unless otherwise stated. these parameters are for design guidance only and are not tested. t0cki t1cki 40 41 42 45 46 47 48 tmr0 or tmr1
PIC12F683 ds41211a-page 132 advance information ? 2003 microchip technology inc. figure 15-10: capture/compare/pwm timings (ccp) table 15-6: capture/compare/pwm requirements (ccp) standard operating conditions (unless otherwise stated) operating temperature - 40c  t a  +125c param no. symbol characteristic min typ? max units conditions 50* tccl ccp1 input low time no prescaler 0.5t cy + 20 ?? ns with prescaler 20 ? ? ns 51* tcch ccp1 input high time no prescaler 0.5t cy + 20 ?? ns with prescaler 20 ? ? ns 52* tccp ccp1 input period 3t cy + 40 n ? ? ns n = prescale value (1,4 or 16) 53* tccr ccp1 output rise time ? 25 50 ns 54* tccf ccp1 output fall time ? 25 45 ns * these parameters are characterized but not tested. ? data in ?typ? column is at 5v, 25c unless otherwise stated. these parameters are for design guidance only and are not tested. note: refer to figure 15-4 for load conditions. (capture mode) 50 51 52 53 54 ccp1 (compare or pwm mode) ccp1
? 2003 microchip technology inc. advance information ds41211a-page 133 PIC12F683 table 15-7: comparator specifications table 15-8: comparator voltage reference specifications standard operating conditions (unless otherwise stated) operating temperature -40c  t a  +125c sym characteristics min typ max units comments v os input offset voltage ? 5.0 10 mv v cm input common mode voltage 0 ? v dd - 1.5 v c mrr common mode rejection ratio +55* ? ? db t rt response time (1) ? 150 400* ns t mc 2 co v comparator mode change to output valid ?? 10* s * these parameters are characterized but not tested. note 1: response time measured with one comparator input at (v dd - 1.5)/2 while the other input transitions from v ss to v dd - 1.5v. standard operating conditions (unless otherwise stated) operating temperature -40c  t a  +125c sym. characteristics min typ max units comments resolution ? ? v dd /24* v dd /32 ? ? lsb lsb low range (vrr = 1) high range (vrr = 0) absolute accuracy ? ? ? ? 1/4* 1/2* lsb lsb low range (vrr = 1) high range (vrr = 0) unit resistor value (r) ? 2k* ?  settling time (1) ?? 10* s * these parameters are characterized but not tested. note 1: settling time measured while vrr = 1 and vr<3:0> transitions from ?0000? to ?1111? .
PIC12F683 ds41211a-page 134 advance information ? 2003 microchip technology inc. table 15-9: PIC12F683 a/d converter characteristics : standard operating conditions (unless otherwise stated) operating temperature -40c  t a  +125c param no. sym characteristic min typ? max units conditions a01 n r resolution ? ? 10 bit a02 e abs total absolute error* (1) ?? 1lsbv ref = 5.0v a03 e il integral error ? ? 1lsbv ref = 5.0v a04 e dl differential error ? ? 1 lsb no missing codes to 10 bits v ref = 5.0v a05 e fs full scale range 2.2* ? 5.5* v a06 e off offset error ? ? 1lsbv ref = 5.0v a07 e gn gain error ? ? 1lsbv ref = 5.0v a10 ? monotonicity ? guaranteed (2) ??v ss  v ain  v ref + a20 a20a v ref reference voltage 2.2 2.5 ?v dd + 0.3 v dd + 0.3 v 0c  t a  +125c absolute limits to ensure 10-bit accuracy a25 v ain analog input voltage v ss ?v ref v a30 z ain recommended impedance of analog voltage source ?? 10k  a50 i ref v ref input current* (3) 10 ? ? ? 1000 10 a a during v ain acquisition. based on differential of v hold to v ain . during a/d conversion cycle. * these parameters are characterized but not tested. ? data in ?typ? column is at 5.0v, 25 c unless otherwise stated. these parameters are for design guidance only and are not tested. note 1: total absolute error includes integral, differential, offset and gain errors. 2: the a/d conversion result never decreases with an increase in the input voltage and has no missing codes. 3: v ref current is from external v ref or v dd pin, whichever is selected as reference input. 4: when a/d is off, it will not consume any current other than leakage current. the power-down current spec includes any such leakage from the a/d module.
? 2003 microchip technology inc. advance information ds41211a-page 135 PIC12F683 figure 15-11: PIC12F683 a/d conversion timing (normal mode) table 15-10: PIC12F683 a/d conversion requirements standard operating conditions (unless otherwise stated) operating temperature -40c  t a  +125c param no. sym characteristic min typ? max units conditions 130 t ad a/d clock period 1.6 ? ? st osc based, v ref
3.0v 3.0* ? ? st osc based, v ref full range 130 t ad a/d internal rc oscillator period 3.0* 6.0 9.0* s adcs<1:0> = 11 (rc mode) at v dd = 2.5v 2.0* 4.0 6.0* sat v dd = 5.0v 131 t cnv conversion time (not including acquisition time) (1) ?11? t ad set go bit to new data in a/d result register 132 t acq acquisition time 5* 11.5 ? ? ? s s the minimum time is the amplifier settling time. this may be used if the ?new? input voltage has not changed by more than 1 lsb (i.e., 4.1 mv @ 4.096v) from the last sampled voltage (as stored on c hold ). 134 t go q4 to a/d clock start ?t osc /2 ? ? if the a/d clock source is selected as rc, a time of t cy is added before the a/d clock starts. this allows the sleep instruction to be executed. * these parameters are characterized but not tested. ? data in ?typ? column is at 5.0v, 25 c unless otherwise stated. these parameters are for design guidance only and are not tested. note 1: adresh and adresl registers may be read on the following t cy cycle. 2: see table 10-1 for minimum conditions. 131 130 132 bsf adcon0, go q4 a/d clk a/d data adres adif go sample old_data sampling stopped done new_data 987 3210 note 1: if the a/d clock source is selected as rc, a time of t cy is added before the a/d clock starts. this allows the sleep instruction to be executed. 1 t cy 6 134 (t osc /2) (1) 1 t cy
PIC12F683 ds41211a-page 136 advance information ? 2003 microchip technology inc. figure 15-12: PIC12F683 a/d conversion timing (sleep mode) table 15-11: PIC12F683 a/d conversion requirements (sleep mode) standard operating conditions (unless otherwise stated) operating temperature -40c  t a  +125c param no. sym characteristic min typ? max units conditions 130 t ad a/d internal rc oscillator period 3.0* 6.0 9.0* s adcs<1:0> = 11 (rc mode) at v dd = 2.5v 2.0* 4.0 6.0* sat v dd = 5.0v 131 tcnv conversion time (not including acquisition time) (1) ?11?t ad 132 t acq acquisition time (2) 5* 11.5 ? ? ? s s the minimum time is the amplifier settling time. this may be used if the ?new? input voltage has not changed by more than 1 lsb (i.e., 4.1 mv @ 4.096v) from the last sampled voltage (as stored on c hold ). 134 t go q4 to a/d clock start ?t osc /2 + t cy ? ? if the a/d clock source is selected as rc, a time of t cy is added before the a/d clock starts. this allows the sleep instruction to be executed. * these parameters are characterized but not tested. ? data in ?typ? column is at 5.0v, 25 c unless otherwise stated. these parameters are for design guidance only and are not tested. note 1: adres register may be read on the following t cy cycle. 2: see table 10-1 for minimum conditions. 131 130 bsf adcon0, go q4 a/d clk a/d data adres adif go sample old_data sampling stopped done new_data 9 7 3210 note 1: if the a/d clock source is selected as rc, a time of t cy is added before the a/d clock starts. this allows the sleep instruction to be executed. 134 6 8 132 1 t cy (t osc /2 + t cy ) (1) 1 t cy
? 2003 microchip technology inc. advance information ds41211a-page 137 PIC12F683 16.0 packaging information 16.1 package marking information xxxxxnnn 8-lead pdip (skinny dip) example xxxxxxxx yyww /017 12f683-i 0315 xxxxyyww 8-lead soic xxxxxxxx nnn /0315 example 12f683-e 017 8-lead dfn-s xxxxxxx nnn xxxxxxx xxyyww -e/021 017 12f683 0315 example legend: xx...x customer specific information* y year code (last digit of calendar year) yy year code (last 2 digits of calendar year) ww week code (week of january 1 is week ?01?) nnn alphanumeric traceability code note : in the event the full microchip part number cannot be marked on one line, it will be carried over to the next line thus limiting the number of available characters for customer specific information. * standard picmicro device marking consists of microchip part number, year code, week code, and traceability code. for picmicro device marking beyond this, certain price adders apply. please check with your microchip sales office. for qtp devices, any special marking adders are included in qtp price.
PIC12F683 ds41211a-page 138 advance information ? 2003 microchip technology inc. 16.2 package details the following sections give the technical details of the packages. 8-lead plastic dual in-line (p) ? 300 mil (pdip) b1 b a1 a l a2 p e eb c e1 n d 1 2 units inches* millimeters dimension limits min nom max min nom max number of pins n 88 pitch p .100 2.54 top to seating plane a .140 .155 .170 3.56 3.94 4.32 molded package thickness a2 .115 .130 .145 2.92 3.30 3.68 base to seating plane a1 .015 0.38 shoulder to shoulder width e .300 .313 .325 7.62 7.94 8.26 molded package width e1 .240 .250 .260 6.10 6.35 6.60 overall length d .360 .373 .385 9.14 9.46 9.78 tip to seating plane l .125 .130 .135 3.18 3.30 3.43 lead thickness c .008 .012 .015 0.20 0.29 0.38 upper lead width b1 .045 .058 .070 1.14 1.46 1.78 lower lead width b .014 .018 .022 0.36 0.46 0.56 overall row spacing eb .310 .370 .430 7.87 9.40 10.92 mold draft angle top 51015 51015 mold draft angle bottom 51015 51015 * controlling parameter notes: dimensions d and e1 do not include mold flash or protrusions. mold flash or protrusions shall not exceed jedec equivalent: ms-001 drawing no. c04-018 .010? (0.254mm) per side. significant characteristic
? 2003 microchip technology inc. advance information ds41211a-page 139 PIC12F683 8-lead plastic small outline (sn) ? narrow, 150 mil (soic) foot angle 048048 15 12 0 15 12 0 mold draft angle bottom 15 12 0 15 12 0 mold draft angle top 0.51 0.42 0.33 .020 .017 .013 b lead width 0.25 0.23 0.20 .010 .009 .008 c lead thickness 0.76 0.62 0.48 .030 .025 .019 l foot length 0.51 0.38 0.25 .020 .015 .010 h chamfer distance 5.00 4.90 4.80 .197 .193 .189 d overall length 3.99 3.91 3.71 .157 .154 .146 e1 molded package width 6.20 6.02 5.79 .244 .237 .228 e overall width 0.25 0.18 0.10 .010 .007 .004 a1 standoff 1.55 1.42 1.32 .061 .056 .052 a2 molded package thickness 1.75 1.55 1.35 .069 .061 .053 a overall height 1.27 .050 p pitch 8 8 n number of pins max nom min max nom min dimension limits millimeters inches* units 2 1 d n p b e e1 h l c 45 a2 a a1 * controlling parameter notes: dimensions d and e1 do not include mold flash or protrusions. mold flash or protrusions shall not exceed .010? (0.254mm) per side. jedec equivalent: ms-012 drawing no. c04-057 significant characteristic
PIC12F683 ds41211a-page 140 advance information ? 2003 microchip technology inc. 8-lead plastic dual flat no lead package (mf) 6x5 mm body (dfn-s) nom .050 bsc inches .194 bsc .184 bsc .226 bsc .236 bsc .008 ref. d overall width jedec equivalent: pending notes: drawing no. c04-113 molded package width lead width *controlling parameter mold draft angle top tie bar width lead length r b l d1 .014 .020 dimension limits molded package thickness pitch overall height overall length molded package length base thickness standoff number of pins a3 e1 e a2 a1 a .000 units n p min top view 12 a2 a 5.99 bsc .019 12 .030 .014 .016 .024 0.35 0.50 .356 0.40 0.60 5.74 bsc 12 0.47 0.75 millimeters* .039 .002 .031 .026 .0004 .033 0.00 8 max min 1.27 bsc 0.20 ref. 4.92 bsc 4.67 bsc 0.85 0.01 0.65 0.80 0.05 1.00 max nom 8 bottom view n e e1 pin 1 p b exposed pad length e2 exposed pad width d2 .085 .091 .097 2.16 2.31 2.46 .152 .158 .163 3.85 4.00 4.15 exposed metal pads d2 e2 a1 a3 l id d1 d r dimensions d and e1 do not include mold flash or protrusions. mold flash or protrusions shall not exceed .010? (0.254mm) per si de.
? 2003 microchip technology inc. advance information ds41211a-page 141 PIC12F683 8-lead plastic dual flat no lead package (mf) 6x5 mm body (dfn-s) land pattern and solder mask l m m b solder mask p package edge pad width *controlling parameter drawing no. c04-2113 b .014 .016 .019 0.35 0.40 0.47 pitch max units dimension limits p inches .050 bsc min nom max millimeters* min 1.27 bsc nom pad length pad to solder mask l .020 .024 .030 0.50 0.60 0.75 m .005 .006 0.13 0.15
PIC12F683 ds41211a-page 142 advance information ? 2003 microchip technology inc. notes:
? 2003 microchip technology inc. advance information ds41211a-page 143 PIC12F683 appendix a: data sheet revision history revision a this is a new data sheet. appendix b: migrating from other picmicro ? devices this discusses some of the issues in migrating from other picmicro devices to the pic12f6xx family of devices. b.1 pic1 2f675 t o pic 12f683 table b-1: feature comparison feature pic12f675 PIC12F683 max operating speed 20 mhz 20 mhz max program memory (words) 1024 2048 sram (bytes) 64 128 a/d resolution 10-bit 10-bit data eeprom (bytes) 128 256 timers (8/16-bit) 1/1 2/1 oscillator modes 8 8 brown-out detect y y internal pull-ups gp0/1/2/4/5 gp0/1/2/4/5, mclr interrupt-on-change gp0/1/2/3/ 4/5 gp0/1/2/3/4/5 comparators 1 1 ccp n y ultra low-power wake-up ny extended wdt n y software control option of wdt/bod ny intosc frequencies 4 mhz 32 khz - 8mhz clock switching n y note: this device has been designed to perform to the parameters of its data sheet. it has been tested to an electrical specification designed to determine its conformance with these parameters. due to process differences in the manufacture of this device, this device may have different performance characteristics than its earlier version. these differences may cause this device to perform differently in your application than the earlier version of this device.
PIC12F683 ds41211a-page 144 advance information ? 2003 microchip technology inc. notes:
? 2003 microchip technology inc. advance information ds41211a-page 145 PIC12F683 index a a/d ...................................................................................... 63 acquisition requirements ........................................... 69 associated registers .................................................. 71 block diagram............................................................. 63 calculating acquisition time....................................... 69 channel selection....................................................... 63 configuration and operation....................................... 63 configuring.................................................................. 68 configuring interrupt ................................................... 68 conversion clock........................................................ 64 effects of a reset........................................................ 71 internal sampling switch (r ss ) impedance................ 69 operation during sleep .............................................. 70 output format............................................................. 65 reference voltage (v ref )........................................... 63 source impedance...................................................... 69 specifications............................................ 134, 135, 136 starting a conversion ................................................. 65 absolute maximum ratings .............................................. 115 ac characteristics industrial and extended ............................................ 126 load conditions ........................................................ 125 analog input connection considerations............................ 56 analog-to-digital converter. see a/d assembler mpasm assembler................................................... 109 b block diagrams a/d .............................................................................. 63 analog input model ............................................... 56, 69 capture mode operation ............................................ 50 comparator ................................................................. 58 comparator voltage reference (cv ref ) .................... 60 compare ..................................................................... 51 crystal operation ........................................................ 19 ec operation .............................................................. 20 fail-safe clock monitor (fscm) ................................. 94 gp0 pin....................................................................... 37 gp1 pin....................................................................... 37 gp2 pin....................................................................... 38 gp3 pin....................................................................... 38 gp4 pin....................................................................... 39 gp5 pin....................................................................... 39 in-circuit serial programming connections................ 98 interrupt logic ............................................................. 88 mclr circuit............................................................... 81 on-chip reset circuit ................................................. 80 PIC12F683.................................................................... 5 rc oscillator............................................................... 20 rcio oscillator ........................................................... 20 resonator operation................................................... 20 simplified pwm mode................................................. 52 system clock .............................................................. 25 timer1......................................................................... 43 timer2......................................................................... 48 tmr0/wdt prescaler................................................. 41 ultra low-power wake-up .......................................... 36 watchdog timer (wdt) .............................................. 91 brown-out detect (bod) ..................................................... 82 associated registers .................................................. 83 calibration................................................................... 82 specifications ........................................................... 130 timing and characteristics ....................................... 129 c c compilers mplab c17.............................................................. 110 mplab c18.............................................................. 110 mplab c30.............................................................. 110 capture module. see capture/compare/pwm (ccp) capture/compare/pwm (ccp) .......................................... 49 associated registers.................................................. 54 associated registers w/capture/compare/timer1 .... 51 capture mode............................................................. 50 prescaler ............................................................ 50 ccp1 pin configuration ............................................. 50 compare special trigger output of ccp1 ......................... 51 compare mode........................................................... 51 ccp1 pin configuration ..................................... 51 software interrupt mode ..................................... 51 special event trigger ......................................... 51 timer1 mode selection....................................... 51 pwm mode................................................................. 52 duty cycle .......................................................... 53 example frequencies/resolutions ..................... 53 pwm period ....................................................... 52 tmr2 to pr2 match ........................................... 47 special event trigger and a/d conversions .............. 51 specifications ........................................................... 132 timer resources ........................................................ 49 ccp. see capture/compare/pwm (ccp) clock sources..................................................................... 22 using osccon register ........................................... 22 clock switching .................................................................. 24 exiting sleep............................................................... 32 power-up/wake-up delay........................................... 26 returning to primary oscillator................................... 28 returning to primary oscillator on reset ................... 29 switch to secondary oscillator................................... 27 transition and the watchdog timer ........................... 24 code examples assigning prescaler to timer0.................................... 42 assigning prescaler to wdt....................................... 42 changing between capture prescalers ..................... 50 data eeprom read.................................................. 75 data eeprom write .................................................. 75 indirect addressing..................................................... 18 initializing a/d............................................................. 68 initializing gpio.......................................................... 33 saving status and w registers in ram ..................... 90 ultra low-power wake-up initialization ...................... 36 write verify ................................................................. 75 code protection .................................................................. 98 comparator......................................................................... 55 associated registers.................................................. 62 configurations ............................................................ 57 cout as t1 gate................................................. 44, 59 effects of a reset ....................................................... 61 i/o operating modes .................................................. 57 interrupts .................................................................... 59 operation.................................................................... 56 operation during sleep .............................................. 61 outputs ....................................................................... 59 response time .......................................................... 61
PIC12F683 ds41211a-page 146 advance information ? 2003 microchip technology inc. specifications............................................................ 133 synchronizing cout w/timer1 .................................. 59 comparator voltage reference (cv ref ) ............................ 60 accuracy/error ............................................................ 60 associated registers .................................................. 62 configuring.................................................................. 60 effects of a reset........................................................ 61 response time ........................................................... 61 specifications............................................................ 133 compare module. see capture/compare/pwm (ccp) configuration bits.......................................................... 78, 79 cpu features ..................................................................... 77 d data eeprom memory associated registers .................................................. 76 code protection .................................................... 73, 76 data memory organization ................................................... 7 dc characteristics industrial and extended .................................... 118, 123 demonstration boards picdem 1 ................................................................. 112 picdem 17 ............................................................... 112 picdem 18r pic18c601/801 .................................. 113 picdem 2 plus ......................................................... 112 picdem 3 pic16c92x ............................................. 112 picdem 4 ................................................................. 112 picdem lin pic16c43x ......................................... 113 picdem usb pic16c7x5........................................ 113 picdem.net internet/ethernet .................................. 112 development support ....................................................... 109 device overview ................................................................... 5 e eeprom data memory avoiding spurious write.............................................. 75 reading....................................................................... 75 write verify ................................................................. 75 writing ......................................................................... 75 electrical specifications .................................................... 115 errata .................................................................................... 3 evaluation and programming tools .................................. 113 external clock input ............................................................ 20 f fail-safe clock monitor....................................................... 94 fail-safe mode............................................................ 94 reset and wake-up from sleep .................................. 95 firmware instructions........................................................ 101 fuses. see configuration bits g general purpose register file.............................................. 7 gpio ................................................................................... 33 additional pin functions ............................................. 33 interrupt-on-change............................................ 35 ultra low-power wake-up .................................. 36 weak pull-up....................................................... 33 associated registers .................................................. 40 gp0 ............................................................................. 37 gp1 ............................................................................. 37 gp2 ............................................................................. 38 gp3 ............................................................................. 38 gp4 ............................................................................. 39 gp5 ............................................................................. 39 pin descriptions and diagrams................................... 37 specifications ........................................................... 128 i id locations........................................................................ 98 in-circuit debugger............................................................. 99 in-circuit serial programming (icsp)................................. 98 indirect addressing, indf and fsr registers ................... 18 instruction format............................................................. 101 instruction set................................................................... 101 addlw..................................................................... 103 addwf..................................................................... 103 andlw..................................................................... 103 andwf..................................................................... 103 bcf .......................................................................... 103 bsf........................................................................... 103 btfsc ...................................................................... 103 btfss ...................................................................... 103 call......................................................................... 104 clrf ........................................................................ 104 clrw ....................................................................... 104 clrwdt .................................................................. 104 comf ....................................................................... 104 decf ........................................................................ 104 decfsz ................................................................... 104 goto ....................................................................... 105 incf ......................................................................... 105 incfsz..................................................................... 105 iorlw ...................................................................... 106 iorwf...................................................................... 106 movf ....................................................................... 105 movlw .................................................................... 106 movwf .................................................................... 105 nop .......................................................................... 106 retfie ..................................................................... 106 retlw ..................................................................... 107 return................................................................... 107 rlf ........................................................................... 107 rrf .......................................................................... 107 sleep ...................................................................... 108 sublw ..................................................................... 108 subwf..................................................................... 108 swapf ..................................................................... 108 xorlw .................................................................... 108 xorwf .................................................................... 108 summary table ........................................................ 102 internal oscillator block ...................................................... 21 calibration .................................................................. 21 intosc ...................................................................... 22 specifications ................................................... 127 intrc......................................................................... 22 modes......................................................................... 21 osctune register.................................................... 21 internal sampling switch (r ss ) impedance........................ 69 interrupts............................................................................. 87 a/d.............................................................................. 68 associated registers .................................................. 90 capture ....................................................................... 50 comparator................................................................. 59 compare ..................................................................... 51 context saving ........................................................... 90 data eeprom memory write .................................... 74 gp2/int...................................................................... 89 gpio interrupt-on-change ......................................... 89 interrupt-on-change ................................................... 35 tmr0 .......................................................................... 89 tmr1 .......................................................................... 44
? 2003 microchip technology inc. advance information ds41211a-page 147 PIC12F683 tmr2 to pr2 match ................................................... 48 tmr2 to pr2 match (pwm) ....................................... 47 intosc specifications ..................................................... 127 l load conditions ................................................................ 125 m mclr .................................................................................. 81 internal ........................................................................ 81 memory organization data eeprom memory.............................................. 73 migrating from other picmicro devices ............................ 143 mplab asm30 assembler, linker, librarian ................... 110 mplab icd 2 in-circuit debugger ................................... 111 mplab ice 2000 high performance universal in-circuit em- ulator ......................................................................... 111 mplab ice 4000 high performance universal in-circuit em- ulator ......................................................................... 111 mplab integrated development environment software .. 109 mplink object linker/mplib object librarian ................ 110 o opcode field descriptions ............................................. 101 oscillator associated registers .................................................. 32 oscillator configurations ..................................................... 19 ec ............................................................................... 19 hs ............................................................................... 19 intosc ...................................................................... 19 intoscio................................................................... 19 lp................................................................................ 19 rc......................................................................... 19, 20 rcio ........................................................................... 19 xt ............................................................................... 19 oscillator control register clock transition sequence ......................................... 25 modifying the ircf bits ............................................. 25 oscillator specifications.................................................... 126 oscillator start-up timer (ost) ...... .................................... 81 specifications............................................................ 130 oscillator switching............................................................. 22 fail-safe clock monitor............................................... 94 two-speed clock start-up.......................................... 93 oscillators associated registers .................................................. 32 p packaging ......................................................................... 137 marking ..................................................................... 137 pdip details.............................................................. 138 pcl and pclath ............................................................... 17 computed goto........................................................ 17 stack ........................................................................... 17 pickit 1 flash starter kit................................................... 113 picstart plus development programmer ..................... 111 pin diagram .......................................................................... 2 pinout descriptions PIC12F683.................................................................... 6 power-down mode (sleep) ................................................. 96 power-on reset (por) ....................................................... 81 power-up timer (pwrt) .................................................... 81 specifications............................................................ 130 precision internal oscillator parameters........................... 127 prescaler shared wdt/timer0 ................................................... 42 switching prescaler assignment ................................ 42 primary oscillators.............................................................. 22 pro mate ii universal device programmer ................... 111 product identification ........................................................ 151 program memory organization............................................. 7 programming, device instructions.................................... 101 pulse width modulation. see capture/compare/pwm, pwm mode. r rcio oscillator................................................................... 20 read-modify-write operations ......................................... 101 registers adcon0 (a/d control)............................................... 66 ansel (analog select register)................................ 67 calibration word......................................................... 79 ccp1con/ccp2con (ccp control 1 and ccp control 2) register.......................................................... 49 ccpr1h..................................................................... 49 ccpr1l ..................................................................... 49 cmcon0 (comparator control) register................... 55 cmcon1 (comparator control) register................... 59 configuration word data memory ................................................................ 8 eeadr (eeprom address) ...................................... 73 eecon1 (eeprom control) ..................................... 74 eecon2 (eeprom control) ..................................... 74 eedat (eeprom data) ............................................ 73 gpio........................................................................... 33 intcon (interrupt control) ........................................ 13 ioc (interrupt-on-change) ......................................... 35 option_reg ............................................................ 12 osccon.................................................................... 23 osctune .................................................................. 22 pcon (power control) ......................................... 16, 83 pie1 (peripheral interrupt enable 1) .......................... 14 pir1 (peripheral interrupt 1) ...................................... 15 reset values .............................................................. 85 status ......................................................................... 11 t1con (timer1 control) ............................................ 45 t2con (timer2 control) ............................................ 47 trisio........................................................................ 34 vrcon (voltage reference control) ......................... 62 wdtcon ................................................................... 92 wpu (weak pull-up gpio) ........................................ 34 resets ................................................................................ 80 resonators ......................................................................... 19 revision history................................................................ 143 s secondary oscillator...................... ..................................... 22 software simulator (mplab sim) .................................... 110 software simulator (mplab sim30) ................................ 110 special function registers ................................................... 8 t time-out sequence ............................................................ 83 timer0 ................................................................................ 41 associated registers.................................................. 42 external clock ............................................................ 42 interrupt ...................................................................... 41 operation.................................................................... 41 specifications ........................................................... 131 t0cki ......................................................................... 42 timer1 ................................................................................ 43 associated registers.................................................. 46
PIC12F683 ds41211a-page 148 advance information ? 2003 microchip technology inc. asynchronous counter mode ..................................... 46 reading and writing ........................................... 46 interrupt....................................................................... 44 modes of operations................................................... 44 operation during sleep .............................................. 46 oscillator ..................................................................... 46 prescaler..................................................................... 44 specifications............................................................ 131 timer1 gate inverting gate ..................................................... 44 selecting source........................................... 44, 59 synchronizing cout w/timer1 .......................... 59 tmr1h register ......................................................... 43 tmr1l register.......................................................... 43 timer2 ................................................................................. 47 associated registers .................................................. 48 operation .................................................................... 47 postscaler ................................................................... 47 pr2 register............................................................... 47 prescaler..................................................................... 47 tmr2 register............................................................ 47 tmr2 to pr2 match interrupt ............................... 47, 48 timing diagrams a/d conversion ......................................................... 135 a/d conversion (sleep mode) .................................. 136 brown-out detect (bod) ........................................... 129 brown-out detect situations ....................................... 82 capture/compare/pwm (ccp)................................. 132 clkout and i/o....................................................... 128 comparator output ..................................................... 56 external clock........................................................... 126 fail-safe clock monitor (fscm) ................................. 95 int pin interrupt.......................................................... 89 primary oscillator after reset (ec, rc, intosc)...... 30 primary oscillator after reset (hs, xt, lp) ............... 29 reset, wdt, ost and power-up timer ................... 129 time-out sequence case 1................................................................. 84 case 2................................................................. 84 case 3................................................................. 84 timer0 and timer1 external clock ........................... 131 timer1 incrementing edge.......................................... 44 two speed start-up .................................................... 93 wake-up from interrupt ............................................... 97 timing parameter symbology........................................... 125 two-speed clock start-up mode ........................................ 93 u ultra low-power wake-up................................................... 36 v voltage reference. see comparator voltage reference (cv ref ) v ref . see a/d reference voltage w wake-up using interrupts ................................................... 96 watchdog timer (wdt) ...................................................... 91 associated registers .................................................. 92 clock source............................................................... 91 modes ......................................................................... 91 period.......................................................................... 91 specifications............................................................ 130 www, on-line support........................................................ 3
? 2003 microchip technology inc. advance information ds41211a-page 149 PIC12F683 on-line support microchip provides on-line support on the microchip world wide web site. the web site is used by microchip as a means to make files and information easily available to customers. to view the site, the user must have access to the internet and a web browser, such as netscape ? or microsoft ? internet explorer. files are also available for ftp download from our ftp site. connecting to the microchip internet web site the microchip web site is available at the following url: www.microchip.com the file transfer site is available by using an ftp service to connect to: ftp://ftp.microchip.com the web site and file transfer site provide a variety of services. users may download files for the latest development tools, data sheets, application notes, user's guides, articles and sample programs. a vari- ety of microchip specific business information is also available, including listings of microchip sales offices, distributors and factory representatives. other data available for consideration is:  latest microchip press releases  technical support section with frequently asked questions  design tips  device errata  job postings  microchip consultant program member listing  links to other useful web sites related to microchip products  conferences for products, development systems, technical information and more  listing of seminars and events systems information and upgrade hot line the systems information and upgrade line provides system users a listing of the latest versions of all of microchip's development systems software products. plus, this line provides information on how customers can receive the most current upgrade kits. the hot line numbers are: 1-800-755-2345 for u.s. and most of canada, and 1-480-792-7302 for the rest of the world. 042003
PIC12F683 ds41211a-page 150 advance information ? 2003 microchip technology inc. reader response it is our intention to provide you with the best documentation possible to ensure successful use of your microchip prod- uct. if you wish to provide your comments on organization, clarity, subject matter, and ways in which our documentation can better serve you, please fax your comments to the technical publications manager at (480) 792-4150. please list the following information, and use this outline to provide us with your comments about this document. to : technical publications manager re: reader response total pages sent ________ from: name company address city / state / zip / country telephone: (_______) _________ - _________ application (optional): would you like a reply? y n device: literature number: questions: fax: (______) _________ - _________ ds41211a PIC12F683 1. what are the best features of this document? 2. how does this document meet your hardware and software development needs? 3. do you find the organization of this document easy to follow? if not, why? 4. what additions to the document do you think would enhance the structure and subject? 5. what deletions from the document could be made without affecting the overall usefulness? 6. is there any incorrect or misleading information (what and where)? 7. how would you improve this document?
 2003 microchip technology inc. advance information ds41211a-page 151 PIC12F683 product identification system to order or obtain information, e.g. , on pricing or delivery, refer to the factory or the listed sales office. * jw devices are uv erasable and can be programmed to any device c onfiguration. jw devices meet the electrical requirement of each oscillator type. sales and support part no. x /xx xxx pattern package temperature range device device PIC12F683: standard v dd range PIC12F683t: (tape and reel) temperature range i = -40 c to +85 c e= -40 c to +125 c package p = pdip sn = soic (gull wing, 150 mil body) mf = dfn-s pattern 3-digit pattern code for qtp (blank otherwise) examples: a) PIC12F683 ? e/p 301 = extended temp., pdip package, 20 mhz, qtp pattern #301 b) PIC12F683 ? i/so = industrial temp., soic package, 20 mhz data sheets products supported by a preliminary data sheet may have an errata sheet describing minor operational differences and recommended workarounds. to determine if an errata sheet exists for a particular device, please contact one of the following: 1. your local microchip sales office 2. the microchip corporate literature center u.s. fax: (480) 792-7277 3. the microchip worldwide site (www.microchip.com) please specify which device, revision of silicon and data sheet (include literature #) you are using. new customer notification system register on our web site (www.microchip.com/cn) to receive the most current information on our products.
ds41211a-page 152 advance information ? 2003 microchip technology inc. americas corporate office 2355 west chandler blvd. chandler, az 85224-6199 tel: 480-792-7200 fax: 480-792-7277 technical support: 480-792-7627 web address: http://www.microchip.com atlanta 3780 mansell road, suite 130 alpharetta, ga 30022 tel: 770-640-0034 fax: 770-640-0307 boston 2 lan drive, suite 120 westford, ma 01886 tel: 978-692-3848 fax: 978-692-3821 chicago 333 pierce road, suite 180 itasca, il 60143 tel: 630-285-0071 fax: 630-285-0075 dallas 4570 westgrove drive, suite 160 addison, tx 75001 tel: 972-818-7423 fax: 972-818-2924 detroit tri-atria office building 32255 northwestern highway, suite 190 farmington hills, mi 48334 tel: 248-538-2250 fax: 248-538-2260 kokomo 2767 s. albright road kokomo, in 46902 tel: 765-864-8360 fax: 765-864-8387 los angeles 18201 von karman, suite 1090 irvine, ca 92612 tel: 949-263-1888 fax: 949-263-1338 phoenix 2355 west chandler blvd. chandler, az 85224-6199 tel: 480-792-7966 fax: 480-792-4338 san jose 2107 north first street, suite 590 san jose, ca 95131 tel: 408-436-7950 fax: 408-436-7955 toronto 6285 northam drive, suite 108 mississauga, ontario l4v 1x5, canada tel: 905-673-0699 fax: 905-673-6509 asia/pacific australia suite 22, 41 rawson street epping 2121, nsw australia tel: 61-2-9868-6733 fax: 61-2-9868-6755 china - beijing unit 915 bei hai wan tai bldg. no. 6 chaoyangmen beidajie beijing, 100027, no. china tel: 86-10-85282100 fax: 86-10-85282104 china - chengdu rm. 2401-2402, 24th floor, ming xing financial tower no. 88 tidu street chengdu 610016, china tel: 86-28-86766200 fax: 86-28-86766599 china - fuzhou unit 28f, world trade plaza no. 71 wusi road fuzhou 350001, china tel: 86-591-7503506 fax: 86-591-7503521 china - hong kong sar unit 901-6, tower 2, metroplaza 223 hing fong road kwai fong, n.t., hong kong tel: 852-2401-1200 fax: 852-2401-3431 china - shanghai room 701, bldg. b far east international plaza no. 317 xian xia road shanghai, 200051 tel: 86-21-6275-5700 fax: 86-21-6275-5060 china - shenzhen rm. 1812, 18/f, building a, united plaza no. 5022 binhe road, futian district shenzhen 518033, china tel: 86-755-82901380 fax: 86-755-8295-1393 china - shunde room 401, hongjian building no. 2 fengxiangnan road, ronggui town shunde city, guangdong 528303, china tel: 86-765-8395507 fax: 86-765-8395571 china - qingdao rm. b505a, fullhope plaza, no. 12 hong kong central rd. qingdao 266071, china tel: 86-532-5027355 fax: 86-532-5027205 india divyasree chambers 1 floor, wing a (a3/a4) no. 11, o?shaugnessey road bangalore, 560 025, india tel: 91-80-2290061 fax: 91-80-2290062 japan benex s-1 6f 3-18-20, shinyokohama kohoku-ku, yokohama-shi kanagawa, 222-0033, japan tel: 81-45-471- 6166 fax: 81-45-471-6122 korea 168-1, youngbo bldg. 3 floor samsung-dong, kangnam-ku seoul, korea 135-882 tel: 82-2-554-7200 fax: 82-2-558-5932 or 82-2-558-5934 singapore 200 middle road #07-02 prime centre singapore, 188980 tel: 65-6334-8870 fax: 65-6334-8850 taiwan kaohsiung branch 30f - 1 no. 8 min chuan 2nd road kaohsiung 806, taiwan tel: 886-7-536-4818 fax: 886-7-536-4803 taiwan taiwan branch 11f-3, no. 207 tung hua north road taipei, 105, taiwan tel: 886-2-2717-7175 fax: 886-2-2545-0139 europe austria durisolstrasse 2 a-4600 wels austria tel: 43-7242-2244-399 fax: 43-7242-2244-393 denmark regus business centre lautrup hoj 1-3 ballerup dk-2750 denmark tel: 45-4420-9895 fax: 45-4420-9910 france parc d?activite du moulin de massy 43 rue du saule trapu batiment a - ler etage 91300 massy, france tel: 33-1-69-53-63-20 fax: 33-1-69-30-90-79 germany steinheilstrasse 10 d-85737 ismaning, germany tel: 49-89-627-144-0 fax: 49-89-627-144-44 italy via quasimodo, 12 20025 legnano (mi) milan, italy tel: 39-0331-742611 fax: 39-0331-466781 netherlands p. a. de biesbosch 14 nl-5152 sc drunen, netherlands tel: 31-416-690399 fax: 31-416-690340 united kingdom 505 eskdale road winnersh triangle wokingham berkshire, england rg41 5tu tel: 44-118-921-5869 fax: 44-118-921-5820 07/28/03 w orldwide s ales and s ervice


▲Up To Search▲   

 
Price & Availability of PIC12F683

All Rights Reserved © IC-ON-LINE 2003 - 2022  

[Add Bookmark] [Contact Us] [Link exchange] [Privacy policy]
Mirror Sites :  [www.datasheet.hk]   [www.maxim4u.com]  [www.ic-on-line.cn] [www.ic-on-line.com] [www.ic-on-line.net] [www.alldatasheet.com.cn] [www.gdcy.com]  [www.gdcy.net]


 . . . . .
  We use cookies to deliver the best possible web experience and assist with our advertising efforts. By continuing to use this site, you consent to the use of cookies. For more information on cookies, please take a look at our Privacy Policy. X